I am using KendoUI Grid to display my data in a KnockoutJS MVVM enabled application. Since MVVM is the architecture for client side, I am maintaining a knockoutjs observerble array and loading data to that array from the server.
self.loadForGrid = function() {
$.ajax({
url: "api/matchingservicewebapi/GetAllMatchItemForClient/1",
type: 'GET',
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (data) {
console.log(data);
$.each(data, function (i, obj) {
self.users.push(self.items.push({ BirthDate: obj.BDate, Ref: obj.Ref, Amount: obj.Amount, Account: obj.Account, MatchItem_Id: obj.MatchItem_Id }));
});
window.alert('User(s) loaded successfully');
},
statusCode: {
401: function (jqXHR, textStatus, errorThrown) {
alert('Error loading users2');
}
}
});
};
This works fine. But I want to implement pagination for my grid. I can do it the client side like this. This is my viewmodel code.
self.items = ko.observableArray([]);
ko.bindingHandlers.kendoGrid.options = {
groupable: true,
scrollable: true,
sortable: true,
pageable: {
pageSizes: [5, 10, 15]
}
};
And this is my binding in HTML file (I have used the Knockout-Kendo.js).
<div data-bind="kendoGrid: items"> </div>
But what I want is to enable server pagination. Which means I want the data to be again loaded (lets say data of page 2) to my knockoutjs observable array when I go to next page (when I go to page 2). How can I do that?
Thank you in advance.