jQuery UI Widgets › Forums › Plugins › Data Adapter › Assigning same adapter for two dropdownbox ?
Tagged: data adapter, dataadapter, DropDownList, jqxDataAdapter, jqxDropDownList, multiple, source
This topic contains 1 reply, has 2 voices, and was last updated by Dimitar 10 years, 10 months ago.
-
Author
-
Hi
I was facing an issue when i have assigned same adapter for more thanone dropdownbox on same page ?
Is there any restriction that on adapter should be assigned to one element ?
var emptyRecords = new Array();
var dummySource = {datafields: dataFields, localdata: emptyRecords}
var dummyAdapter = new $.jqx.dataAdapter(dummySource);$(‘#comboBoxBrand’).jqxDropDownList({source: dummyAdapter});
$(“#comboBoxBrand”).jqxDropDownList(‘insertAt’, { label: ‘– All Brands –‘, value: ‘0’}, 0 );$(‘#comboBoxGroup’).jqxDropDownList({source: dummyAdapter});
$(“#comboBoxGroup”).jqxDropDownList(‘insertAt’, { label: ‘– All Groups –‘, value: ‘0’}, 0 );Thanks
Hello mallepaddi,
It is possible to bind two instances of jqxDropDownList to the same data adapter. Here is an example, based on the demo Binding to JSON Data:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" /> <script type="text/javascript" src="../../scripts/gettheme.js"></script> <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/jqxlistbox.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxdropdownlist.js"></script> <script type="text/javascript"> $(document).ready(function () { var theme = ""; var url = "../sampledata/customers.txt"; // prepare the data var source = { datatype: "json", datafields: [ { name: 'CompanyName' }, { name: 'ContactName' } ], url: url, async: false }; var dataAdapter = new $.jqx.dataAdapter(source); // Create a jqxDropDownList $("#jqxDropDownList1").jqxDropDownList({ selectedIndex: 0, source: dataAdapter, displayMember: "ContactName", valueMember: "CompanyName", width: 200, height: 25, theme: theme }); $("#jqxDropDownList2").jqxDropDownList({ selectedIndex: 0, source: dataAdapter, displayMember: "ContactName", valueMember: "CompanyName", width: 200, height: 25, theme: theme }); }); </script> </head> <body> <div id='content'> <div id='jqxDropDownList1'> </div> <div id='jqxDropDownList2'> </div> </div> </body> </html>
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.