jQuery UI Widgets › Forums › Grid › help me about combobox
Tagged: cascading, cascading comboboxes, cellvaluechanging, combobox, createeditor, custom, editor, grid, jqxgrid, selectedIndex, setcellvalue
This topic contains 3 replies, has 2 voices, and was last updated by Dimitar 9 years, 11 months ago.
-
Authorhelp me about combobox Posts
-
Hi all,
I ‘ve a problem about selectIndex into the combobox, pls help me solve it!column :
Ma SP (sp1,sp2,sp3,sp4,sp5);
Ten SP (break, milk,egg, soup, water);
respectively
sp1 -> break
sp2 -> milk
sp3 -> egg
sp4 -> soup
sp5 -> waterI want to choose value to “Ten SP” then the combobox of “Ma SP” show value respectively
example :
I choose sp1 to “Ma SP” then “Ten SP” is break.
{ text: 'Ma SP', datafield: 'masp' ,columntype: 'combobox', width: 120, createeditor: function (row, cellvalue, editor) { var source = { datatype: "json", datafields: [ { name: 'masp' } ], id: 'id', url: 'php/get_data_column_masanpham.php', async: false }; var dataAdapterSP = new $.jqx.dataAdapter(source); editor.jqxComboBox({ selectedIndex: cellvalue, source: dataAdapterSP, displayMember: "masp", valueMember: "masp", width: 200, height: 25, theme: theme }); editor.bind('select', function (event) { if (event.args) { var item = event.args.item; if (item) { return item.value; } } }); } }, { text: "Ten SP", datafield: 'tensp' ,columntype: 'combobox', width: 200, createeditor: function (row, cellvalue, editor) { var source = { datatype: "json", datafields: [ { name: 'tensp' } ], id: 'id', url: 'php/get_data_column_tensanpham.php', async: false }; var dataAdapterSP = new $.jqx.dataAdapter(source); editor.jqxComboBox({ selectedIndex: cellvalue, source: dataAdapterSP, displayMember: "tensp", valueMember: "tensp", width: 200, height: 25, theme: theme }); editor.bind('select', function (event) { //var selTaxCodeIndex = editor.jqxComboBox('getSelectedIndex'); //$("#jqxgrid").jqxGrid('setcellvalue', 0, 'masp', selTaxCodeIndex); if (event.args) { var item = event.args.item; if (item) { //$("#jqxListBox").jqxGrid('selectIndex', 0 ); return item.value; } } }); }, initeditor: function (row, column, editor) { //editor.jqxComboBox('selectIndex', 0); }, // update the editor's value before saving it. cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { // return the old value, if the new value is empty. if (newvalue == "") return oldvalue; } }
Hello bachkylan,
I am not exactly sure what your requirement is. Do you need something like our demo Cascading ComboBoxes? If not, please specify what errors are thrown in your browser’s console when you are running this code. Please also note that unless ‘masp’ and ‘tensp’ are numeric fields, the selectedIndex properties will be set to non-numeric values which is not allowed.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Hi Dimitar, Thanks for your reply!
I ‘ve two column as this photo, I choose value to “Tên hàng” column, then “Mã SP” column show respectively value with index of “Tên hàng ” column
I can get index of “Tên hàng” column but i don’t know set index for “Mã SP” column.
<br />hebergeur image<br /><br />
I hope you ‘ll understand my problem.
Thanks!
Hi bachkylan,
Please take a careful look at the example we provided. The functionality you require is achieved by calling setcellvalue in the callback function cellvaluechanging.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.