I'm using the latest versions pf Knockout, Kendo and the Knockout-Kendo bindings, but I'm having trouble getting this simple example to bind. I'd like to bidn the grid to the observable array. I'd also like to bind the paging parameters to the corresponding observable properties in the model. What am I missing here that's preventing the grid from binding to the data correctly? How so I bind the pager properties?
Here's the HTML code.
<div><h2>Names List</h2></div>
<div data-bind="kendoGrid: { data: names, rowTemplate: 'rowTmpl', useKOTemplates: true, paging: { pageSize: 3} }"></div>
<div id="pager"></div>
<script id="rowTmpl" type="text/html">
<tr>
<td data-bind="text: $data"></td>
</tr>
</script>
<script>
var vm = new ViewModel();
ko.applyBindings(vm);
</script>
and here's the Javascript
var ViewModel = function () {
var self = this;
self.selectedPageSize = ko.observable(3);
self.selectedPage = ko.observable(1);
self.totalPages = ko.observable();
self.names = ko.observableArray(["Fred", "Barney", "Wilma", "Betty", "Tom", "Dick", "Harry"]);
}
self.names = ko.observableArray(["Fred", "Barney", "Wilma", "Betty", "Tom". "Dick", "Harry"]);
(.
instead of,
after"Tom"
) – GôTôko.applyBindings
after yourViewModel
function. Is this what you have? fiddle – GôTô