input.kendoComboBox({ dataTextField: 'label', dataValueField: 'id', dataSource: { type: "json", serverFiltering: true, transport: { read: { url: 'api/getchoices, data: { filter: function(){ return input.val(); } } } } } });<input data-role="combobox" data-bind="value: id"/><div id="foo" data-role="view"> <a data-role="button" data-badge="1" data-click="resetClicks">Reset Badge Count</a></div><script>var app = new kendo.mobile.Application();function resetClicks() { this.badge(0); //set new badge value}</script>
success: function () { foundItem = false; $("#tree").data("kendoTreeView").dataSource.read(); }function onBound(e) { if (toSelectText != null && !foundItem) { var treeview = $("#tree").data("kendoTreeView"); var selectitem = treeview.findByText(toSelectText); if (treeview.text(selectitem) == toSelectText) { treeview.select(selectitem); treeview.trigger("select", { node: selectitem }); foundItem = true; } } };
var t94StragglerCarriers = new kendo.data.DataSource({
transport: {
read: {
url: "/MenuTrain/T94StragglerCarriers",
dataType: "json"
},
schema: {
model: {
id: "id",
fields: {
id: {type : "string"} ,
val: {type : "string"}
}
}
},
pageSize: 5,
serverPaging : true
}
});
I've tried several variations for the datasource. From not specifying the schema to just specifying the id.
function onChange() {
var listView = $("#carrierList").data("kendoListView");
var index = listView.select().index();
var item = listView.dataSource.view()[index];
console.log("Item " + index + " selected. Text = " + item.id);
}
Here is the json string returned from my controller's action method:
[{"id":"10eac72a-d62d-434f-8505-4869cdb27b04","val":"CHTT"},{"id":"10eac72a-d62d-434f-8505-4869cdb27b04","val":"CMO "},{"id":"10eac72a-d62d-434f-8505-4869cdb27b04","val":"CTCX"},{"id":"10eac72a-d62d-434f-8505-4869cdb27b04","val":"DBUX"},{"id":"10eac72a-d62d-434f-8505-4869cdb27b04","val":"GATX"},{"id":"10eac72a-d62d-434f-8505-4869cdb27b04","val":"MWCX"},{"id":"10eac72a-d62d-434f-8505-4869cdb27b04","val":"NDYX"},{"id":"10eac72a-d62d-434f-8505-4869cdb27b04","val":"PLMX"},{"id":"10eac72a-d62d-434f-8505-4869cdb27b04","val":"TAEX"},{"id":"10eac72a-d62d-434f-8505-4869cdb27b04","val":"TCIX"},{"id":"10eac72a-d62d-434f-8505-4869cdb27b04","val":"TEIX"},{"id":"10eac72a-d62d-434f-8505-4869cdb27b04","val":"TILX"},{"id":"10eac72a-d62d-434f-8505-4869cdb27b04","val":"UP "},{"id":"ffbcdb6c-4d3a-45f6-8ef6-ada5f28ba44b","val":"MDXx"}]
The listview renders correctly. But it's as if the listview's select().index() methods are treating each field as an item. For example , the first object's id field is index 0, the first object's val field is index 1, and so on.
What am i doing wrong here?