I am doing some experiments with Kendo, Knockout and kendo-knockoutjs libraries. I want to use knockout view model with kendo datasource and to bind it to the kendo grid widget.
In Kendo:
html:
<div id="main">
<div id="reportGrid" data-bind="source: gridDataSource"></div>
</div>
javascript:
var billingReportViewModel = kendo.observable({
gridDataSource: new kendo.data.DataSource({data:[{name:"Apple", color:"green"},{name:"Banana", color:"yellow"}]})
});
$("#reportGrid").kendoGrid();
kendo.bind($("#main"), billingReportViewModel);
http://jsfiddle.net/zeQMT/71/
What I want to accomplish:
The html is the same as the example above.
javascript:
var billingReportViewModel = ko.observable({
gridDataSource: new kendo.data.DataSource({data:[{name:"Apple", color:"green"},{name:"Banana", color:"yellow"}]})
});
$("#reportGrid").kendoGrid();
ko.applyBindings(billingReportViewModel);
http://jsfiddle.net/zeQMT/72/
Obviuosly, this will not work because knockoutjs does not have source
binding. Is it possible to create custom binding named source
so that the current example will work? Any help with working code will be greatly appreciated. Thanks!