ListView Definition
var carriers = $("#carrierList").kendoListView({
dataSource: t94StragglerCarriers,
selectable: true,
pageable : true ,
change: onChange,
dataBound: onDataBound,
dataBinding : onDataBinding ,
template : kendo.template($("#carrierTemplate").html())
}).data("kendoListView");
Template Definition
<script type="text/x-kendo-tmpl" id="carrierTemplate"><div id='carrierListVal' class='k-textbox'>#:val#</div>
<br/>
</script>
DataSource Definition
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.
OnChange Event Handler Definition
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?