Forum


11:56

04/06/2010

Hi,
Given a grid with several columns, let's say first column contains groups, and second one a group's subunits (one-to-many relationship).
Now, in edit mode, I want second column to turn into a dropdown, and I want it to be populated depending on first column (to change a group's current unit, one can choose from a set of units which 'feed' the drop-down, but this is not the whole set of units in database, but a subset depending on the group's id).
I have something like:
{
name: "group",
index: "group",
width: 100,
editable: false
},
{
name: "unit",
index: "unit",
width: 150,
editable: true,
edittype: "select",
editoptions: {
value: unitsForCurrentGroup
}
},
unitsForCurrentGroup is a javascript variable and grid is an inline grid.
I tried to use an onedit - oneditfunc - handler, which is indeed passed the edited row's id (which is equal to group id in my case) and that method returns a group's units and stores them in unitsForCurrentGroup.
Still no luck, in edit mode my drop down is empty (I suppose the value for editoptions must be known at grid loading time, not just when editing a row?)
Thanks,
Karina
Karina,
In your group you should have something similar :
editoptions: {
value: FunctionToGetTheInitialListofItems(),
dataEvents: [
{ type: 'change',
fn: function (e) {
var selected= $(e.target).val(); //Get the type of cooperation id
var newvalues = FunctionToGetTheSecondDropDownValues(mtype).split(";"); // split the lines
var DropDowncontructor= "";
if (newvalues!= "") {
for (var i = 0; i < tcoops.newvalues; i++) {
var newvalues= newvalues[i].split(":");
DropDowncontructor+= '<option value="' + newvalues[0] + '">' + newvalues[1] + '</option>' // the is the value and the ID
}
}
$("#unit").html(DropDowncontructor);
}
}]
},
This is not tested ... not 100% correct, but is very near that (maybe 95%).
Best regards,
Most Users Ever Online: 715
Currently Online:
59 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66