jQuery UI Widgets › Forums › Lists › ComboBox › Using the same source for multiple combos
Tagged: async, combobox, dataadapter, dataBind, jqxComboBox, loadComplete
This topic contains 1 reply, has 2 voices, and was last updated by Nadezhda 9 years, 10 months ago.
Viewing 2 posts - 1 through 2 (of 2 total)
-
Author
-
Not sure if this is a dataAdapter query or comboBox but here is my sample code:
var modulesSource = { datatype: "csv", datafields: [ { name: 'Page' }, { name: 'Category' }, { name: 'Icon' }, { name: 'PageFile' }, { name: 'SecuritySetting' } ], url: "includes/getAllModules.asp?user=test" }; var allModulesData = new $.jqx.dataAdapter(modulesSource); $("#comboModule1").jqxComboBox({ source: allModulesData, displayMember:"Page", valueMember:"Page", width: '240'}); $("#comboModule2").jqxComboBox({ source: allModulesData, displayMember:"Page", valueMember:"Page", width: '240'}); $("#comboModule3").jqxComboBox({ source: allModulesData, displayMember:"Page", valueMember:"Page", width: '240'}); $("#comboModule4").jqxComboBox({ source: allModulesData, displayMember:"Page", valueMember:"Page", width: '240'});
This seems to be really inificiant because its fetching the data 4 times (once for each combo). Is there a more efficient way i can do this and call the data once and populate the 4 combos?
Hello GrantM,
You can use the following example as possible solution.
<!DOCTYPE html> <html lang="en"> <head> <title></title> <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" /> <script type="text/javascript" src="../../scripts/jquery-1.11.1.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/jqxlistbox.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxcombobox.js"></script> <script type="text/javascript"> $(document).ready(function () { var url = '../sampledata/nasdaq_vs_sp500.txt'; var source = { datatype: "csv", datafields: [ { name: 'Date', type: 'date' }, { name: 'S&P 500', type: 'float' }, { name: 'NASDAQ', type: 'float' } ], url: url, async: false }; var dataAdapter = new $.jqx.dataAdapter(source, { loadComplete: function (records) { // get data records. var records = dataAdapter.records; $("#comboModule1").jqxComboBox({ source: records, displayMember: "Date", valueMember: "Date", width: '240' }); $("#comboModule2").jqxComboBox({ source: records, displayMember: "Date", valueMember: "Date", width: '240' }); $("#comboModule3").jqxComboBox({ source: records, displayMember: "Date", valueMember: "Date", width: '240' }); $("#comboModule4").jqxComboBox({ source: records, displayMember: "Date", valueMember: "Date", width: '240' }); alert("loadComplete is called!"); } }); dataAdapter.dataBind(); }); </script> </head> <body> <div id='comboModule1'> </div> <div id='comboModule2'> </div> <div id='comboModule3'> </div> <div id='comboModule4'> </div> </body> </html>
Best Regards,
NadezhdajQWidgets 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.