jQuery UI Widgets › Forums › Grid › Columntype Dropdown get selectedValue
Tagged: grid dropdownlist
This topic contains 5 replies, has 3 voices, and was last updated by Peter Stoev 10 years, 7 months ago.
-
Author
-
Good day.
I have a jqxGrid with columntype Dropdownlist, and i need to get the selectedValue from the Dropdown to save it in the database. There is a way to get the value instead of the index?.Thanks :3
Hi DarkLoki,
The “getcellvalue” method can be used for getting the value of a cell. Example: http://jsfiddle.net/jqwidgets/pyE55/
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Thank you for your reply, unfortunately that wasn’t what i need, but is my fault because i doesn’t explain it right.
I have an editable grid, with a dropdown column and i want to catch the value from the dropdown… not the label. I was wondering if is like the jqxDropdownlist, make an object (var item = $(this).jqxDropdownlist(“getSelectedItem”)) and call the value (item.value).
I left my code if you need to understand what i need:
var selectedIndex = 0; //This is the index, but in my database the id or value im looking for is the same plus one. var data = { datatype: "json", datafields: [ {name : "AlumnoID"}, {name : "Semestre"}, {name : "Nombre"}, {name : "CalificacionFinal"} ], id: "EgresadoID", url: "../../codes/ControlEscolar/Egresados.php", data: { accion : "SelectGrid", AlumnoID : ID }, updaterow: function(rowid, rowdata, commint){ var data = "accion=UpdateRecord&MateriaID=" + selectedIndex + "&EgresadoID=" + rowid + "&Semestre=" + rowdata.Semestre + "&CalificacionFinal=" + rowdata.CalificacionFinal; $.ajax({ dataType: "JSON", url: "../../codes/ControlEscolar/Egresados.php", data: data, success: function(data, status, xhr){ //commit(true); alert("Ok!"); }, error: function(data, status, xhr){ //commit(false); alert("Not Ok!"); } }); selectedIndex = 0; } }; $("#jqxGridEgresados").jqxGrid({ width: 800, height: 305, source: data, pageable: true, editable: true, selectionmode: "multiplecelladvanced", columns: [ {text: "Semestre", columntype: "numberinput", datafield: "Semestre", width: 100, initeditor: function(row, cellvalue, editor){ editor.jqxNumberInput({ spinButtons: true, min: 1, max: 9, decimalDigits: 0, digits: 1, decimal: 1 }); } }, {text: "Materia", columntype: "dropdownlist", datafield: "Nombre", width: 550, initeditor: function (row, cellvalue, editor) { editor.jqxDropDownList({source: dropdownSource, autoDropDownHeight: false, displayMember: "Nombre", valueMember: "MateriaID"}); }, //getting the "id" createeditor: function (row, column, editor){ editor.bind("select", function (event){ selectedIndex = event.args.index + 1; }); } }, {text: "Calificacion Final", columntype: "textbox", datafield: "CalificacionFinal", width: 150} ] });
Waiting for your reply. Thanks :3
Hi DarkLoki,
You would not be able to get the Editor’s value, because it is not stored anywhere. The reason is that your column defines a DropDownList editor, but the column itself is still defined as a simple Text Column. If you want the column to have Text and Value part, then you should specify displayfield and datafield column properties and use this approach: http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/gridkeyvaluescolumnwitharray.htm?arctic.
Hope this helps.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Hello Peter,
Could I get the code link for the link that you posted above?
Hi shashank.bargaje,
Navigate to the Demo and then click the View Source tab to see the code.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.