Comboboxes with shared datasource
HTML
<script src="http://getfirebug.com/firebug-lite-debug.js"></script>
<script src="http://cdn.kendostatic.com/2011.3.1007/js/kendo.all.min.js"></script>
<link rel="stylesheet" href="http://cdn.kendostatic.com/2011.3.1007/styles/kendo.kendo.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2011.3.1007/styles/kendo.common.min.css">
supplier1: <input id="suppliers1" disabled="disabled"/>
supplier2: <input id="suppliers2" disabled="disabled"/>
<button id="load">Load</button>
<button id="getDataItem" disabled="disabled">Get Data Item</button>
<h4>How do I stop them from auto-opening once they have data??</h4>
JavaScript
var dataSource = new kendo.data.DataSource({
type: "odata",
serverFiltering: true
});
var combobox1 = $("#suppliers1").kendoDropDownList({
dataTextField: "CompanyName",
dataValueField: "SupplierID",
dataSource: dataSource,
autoBind: false
}).data("kendoDropDownList");
var combobox2 = $("#suppliers2").kendoDropDownList({
dataTextField: "CompanyName",
dataValueField: "SupplierID",
dataSource: dataSource,
autoBind: false
}).data("kendoDropDownList");
$("#load").click(function() {
$("#getDataItem").attr("disabled", false);
datasource.read("http://services.odata.org/Northwind/Northwind.svc/Suppliers");
combobox1.enable();
combobox2.enable();
$("#getDataItem").attr("disabled", false);
dataSource.fetch();
});
$("#getDataItem").click(function() {
var selectedItem = combobox1._current;
if (selectedItem) {
var dataItem = combobox1.dataSource.view()[selectedItem.index()];
console.log(dataItem);
}
});