jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Using valueMember
Tagged: angular grid, displayMember, DropDownList, dropdownlist editor, editor, grid, jquery grid, jqxgrid, key, value, valueMember
This topic contains 5 replies, has 2 voices, and was last updated by RedantJ 9 years, 6 months ago.
-
AuthorUsing valueMember Posts
-
(I’ll be referencing code I have already posted in a different area)
This is pseudocode of what I would like to accomplish:
// // start pdeudocode: // // For the column 'Room', datafield 'RoomID', displayfield 'rmSchool', columntype 'dropdownlist', width = 80 // // create editor: function (row, value, editor) // // Let valSchoolID = selected school from the School dropdown list // // Loop from the beginning of the adapterRooms array: // // if (valueMember == 0) or (valueMember == valSchoolID) then // add displayMember and valueMember to editor.jqxDropDownList // // move to the next element in the array // // End Loop
This would be a nice feature for what we would like to accomplish. Is this currently possible?
Hello RedantJ,
What I understand from your explanation is that you wish your dropdownlist editor to have the same source as its respective column (“Room”), including both displayMember and valueMember. If that is so, I think the approach showcased in the demo Keys/Values Column may be applicable in your case. If not, I think your pseudocode can be turned into actual, working, JavaScript. The only thing you should probably note is that one data adapter instance can be used for only one widget (the grid and the dropdownlist editor being different widgets).
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Hello Dimitar,
I was able to point myself in the right direction using the jQuery API reference and examining my code closely. I can make a good guess as to what to do. Either it’s going to be something like this:
//. //. //. // other code //. //. //. var cellbeginRoomEdit = function (row, datafield, columntype, value) { if (datafield == "rmSchool") { var SchoolValue = $('#jqxgrid').jqxGrid('getcellvalue', row, "bldSchool"); <% idSchoolValue = request("SchoolValue") sql = "SELECT DISTINCT ROOM FROM tblROOMS WHERE School = " & idSchoolValue set rs = Conn.execute(sql) response.write "var list..... %> // . // . // more code // . // . columns: [ { text: 'School', datafield: 'bldSchool', columntype: 'dropdownlist', width: 150 }, { text: 'Room', datafield: 'rmSchool', columntype: 'dropdownlist', width: 150, cellbeginedit: cellbeginRoomEdit }, ]
….or the code is going to look something like this:
// . // . // . { text: 'Room', columngroup: 'HoldingBin', dataField: 'rmSchool', displayfield: 'RoomID', columntype: 'dropdownlist', width: 180, createeditor: function (row, value, editor) { var SchoolIndex = row; var SchoolValue = $('#jqxgrid').jqxGrid('getcellvalue', row, "bldSchool"); <% idSchoolValue = request("SchoolValue") sql = "SELECT DISTINCT ROOM FROM tblROOMS WHERE School = " & idSchoolValue set rs = Conn.execute(sql) response.write "var list..... %> } },
I feel confident enough that I will find the solution that I’m looking for, thanks to the rich reference guides provided by the jQWidgets team. Cheers!
I just realized that I’m going about this completely the wrong way. What I need to do is this:
// . // Near the top of the code // . <% sql = "SELECT DISTINCT ROOM FROM tblROOMS WHERE" set rs = Conn.execute(sql) response.write "var list..... %>
….from the Server side, to pull ALL data into a two dimensional Javascript array (IE: SchoolNumber, RoomNumer) and close the Server side connection. Then, on the Client Side, figure out some way to put this into an array where jqxGrid can reference it later (IE: pull Roomnumber.value, where SchoolNumber.value = x, and place all Roomnumber.values inside the dropdown list)
…such as this…dagnabbit, the solution was in front of me the whole time.
For the record, this solution works just perfectly:
` { text: ‘Room’, columngroup: ‘HoldingBin’, dataField: ‘rmSchool’, displayfield: ‘RoomID’, columntype: ‘dropdownlist’, width: 180,
initeditor: function (row, cellvalue, editor, celltext, cellwidth, cellheight) {
var valSchool = $(‘#jqxgrid’).jqxGrid(‘getcellvalue’, row, “bldSchool”);
var valRoom = editor.val();
var arrRooms = new Array();
switch (valSchool) {
case “fooHS”:
<%sql = “SELECT DISTINCT ROOM FROM tblRooms WHERE SchoolCode = ‘fooHS'”
Set rs = Conn.execute(sql)response.write “arrRooms = [”
x = 0
do until rs.eof
if x > 0 then
response.write “,”
end if
response.write chr(34) & rs.Fields(“ROOM”).value & chr(34) & “, ”
x = x + 1
rs.movenext
loop
response.write “];”%>
break;
};
editor.jqxDropDownList({ autoDropDownHeight: true, source: arrRooms });
if (arrRooms != “Select a room…”) {
var index = arrRooms.indexOf(valRoom);
editor.jqxDropDownList(‘selectIndex’, index);
}
}
},’ -
AuthorPosts
You must be logged in to reply to this topic.