jQWidgets Forums
jQuery UI Widgets › Forums › Grid › cascading combobox in grid
This topic contains 1 reply, has 2 voices, and was last updated by Dimitar 11 years, 2 months ago.
Viewing 2 posts - 1 through 2 (of 2 total)
-
Author
-
hello,
how to create cascading combobox inside grid.
regards,
raniHello rani,
Please check out the following example, which shows jqxGrid with cascading comboboxes:
<!DOCTYPE html> <html lang="en"> <head> <title id='Description'>This example shows how to implement cascading comboboxes in jqxGrid.</title> <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" /> <script type="text/javascript" src="../../scripts/jquery-1.10.2.min.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxmenu.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.selection.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.pager.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxlistbox.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.edit.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxdropdownlist.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxcombobox.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxpanel.js"></script> <script type="text/javascript" src="../../scripts/demos.js"></script> <script type="text/javascript"> $(document).ready(function () { var data = '[{ "Country": "Belgium", "City": "Brussels"}, {"Country": "France", "City": "Paris"}, {"Country": "USA", "City": "Washington"}]'; // prepare the data var source = { datatype: "json", datafields: [ { name: 'Country', type: 'string' }, { name: 'City', type: 'string' } ], localdata: data }; var dataAdapter = new $.jqx.dataAdapter(source); $("#jqxgrid").jqxGrid( { width: 300, source: dataAdapter, selectionmode: 'singlecell', editable: true, autoheight: true, columns: [ { text: 'Country', datafield: 'Country', width: 150, columntype: 'combobox', cellvaluechanging: function (row, datafield, columntype, oldvalue, newvalue) { if (newvalue != oldvalue) { $("#jqxgrid").jqxGrid('setcellvalue', row, "City", "Select a city..."); }; } }, { text: 'City', datafield: 'City', width: 150, columntype: 'combobox', initeditor: function (row, cellvalue, editor, celltext, cellwidth, cellheight) { var country = $('#jqxgrid').jqxGrid('getcellvalue', row, "Country"); var cities = new Array(); switch (country) { case "Belgium": cities = ["Bruges", "Brussels", "Ghent"]; break; case "France": cities = ["Bordeaux", "Lille", "Paris"]; break; case "USA": cities = ["Los Angeles", "Minneapolis", "Washington"]; break; }; editor.jqxComboBox({ autoDropDownHeight: true, source: cities }); } } ] }); }); </script> </head> <body class='default'> <div id='jqxWidget' style="font-size: 13px; font-family: Verdana; float: left;"> <div id="jqxgrid"> </div> </div> </body> </html>
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/ -
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.