0
votes

I'm running spring web services, using mongodb as backend and kendo ui grid to display data. I'm trying to implement custom server side pagination, as kendo ui grid's serverPagination isn't working for correctly.

I have set up web services that break my json response into different pages as follows.

path/to/json/1
path/to/json/2
path/to/json/3

My question is, is this format compatible with kendo ui grid, if so how could I load this data in the grid page by page.

I change my server side response, as with using specific url's, I ran into the problem where kendo grid assumed that it's all of the data, and thus it only displays one page at the bottom.

Thus now, I return a json array of original size (say 10), and if the pageSize is 5, following is my server's response:

Page 1    Page 2
1           x
2           x
3           x
4           x
5           x
x           6
x           7
x           8
x           9
x           10

where x is an empty obj.

Thus theoretically, on page 1, kendo grid would load the first 5 elements and fill page two with empty ones. And when clicked on page 2, it would load the next five elements and fill page one with empty ones. This way, kendo gird knows the total size of json and can instantiate pages based off of that.

However, the problem I have now is that for page 1, kendo grid loads all 10 elements and the same for page 2, instead of splitting it.

Any idead around this, or is there an efficient way than this?

2

2 Answers

0
votes

If you want to read the values as per the page number than you will have to set up the read url as below:

read: {
   url: "path/to/json/#= getCurrentPage() #"
}

JS:

function getCurrentPage() {
    return $("#grid").data("kendoGrid").dataSource.page();
}

Let me know if above doesn't fulfill your need or you have any query.

0
votes

Using ajax GET request to get the total size of my list, I am able to dynamically change the total variable's value in transport.schema. Now I just need to return the json per page and not do any of my above code. It works fine.