jQWidgets Forums
jQuery UI Widgets › Forums › Lists › ComboBox › selecting from source data
Tagged: datatable
This topic contains 5 replies, has 3 voices, and was last updated by Peter Stoev 10 years, 10 months ago.
-
Author
-
Hello,
This is my scenario, hopefully its not confusing.
I have a datatable that I fill and display for selection, one column is a statusname. I show a form that is for editing. one field is a combobox that is for the status. If I fill the combobox content with displayMember: statusname, valueMember: id , I never get the right selection. If I change the valueMember:statusname then the combobox selects the correct record with the statusname from the datatable.
But, I need the valueMember to be the id(key). So when I update it will pass the id back to the database.
What are the standard routines for handling this method.If I have three(3) fields in the source data. When I select a item, can I reference the other data field in the source which is not part of the value or label?
Thanks you for any replies.
EricHi Eric,
When you want to implement a Custom Editor for jqxDataTable you should implement the createEditor, initEditor and getEditorValue callback functions. The first one is for creating the editor, the second is for synchronization with the current cell’s value and the last one is for saving the selected value. No, you can’t bind the ComboBox to 3 fields – it may have displayMember and valueMember i.e 2 fields. Synchronization with a DB goes through the jqxDataTable’s updateRow callback function of its source object.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Can someone help me about how to get value member of a combobox inside a jqxdatatable editor? By using .val() i can get the display value and when i do ‘getRows’ and iterate through rows i get display name again. Can u pls help me getting the valuemember.
Hi nix,
jqxDataTable does not have ComboBox editor. You can use the “getCellValue” to obtain the cell value in jqxDataTable.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/{text: “ChargeName”,datafield:”ChargeName”, columntype: ‘custom’,
createeditor: function (row, column, editor) {var comboBox = $(“<div class=’dtcombobox’><div/>”).appendTo(editor);
comboBox.jqxComboBox({ source: data.lstExtraCharges,displayMember: “ChargeName”, valueMember: “ExtraChargeUno”});
},
initEditor: function (row, cellValue, editor) {
editor.find(‘input’).val(cellValue);
},
getEditorValue: function (index, value, editor) {
return editor.find(‘input’).val();
}
}this is how i got a combobox inside a datatable. I am getting “ChargeName” displayed as it is set as displaymember. I need to get ExtraChargeUno which is valuemember.
Hi nix,
You cannot get the value of an editor. You can get a value of a cell by using “getCellValue”. The editor edits the value of a cell and your column has only one data field – “ChargeName”. Your DataTable does not know anything about “ExtraChargeUno”. May be you should define the dataField and displayField settings of your column.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.