I'm using a grid with asp.net MVC. Currently the grid is using .DataSource(c => c.Read()) to call a URL that returns an IEnumerable<item> which goes into the grid.
I want to implement paging in the grid. However the data does not have the normal method of paging (count, page number etc.).
Instead when I retrieve my rows I get the data back like this:
{ items: [. . . ], nextPage: 'J23jeg9e93', previousPage: 'oqow0r93285' }
To get the next page you must make the request again for the data, but include the paging token for next or previous page.
At the moment I am only returning the items array. However I want to return all of the data - the items and also the metadata. I must add a button 'Next' and 'Previous' to the grid. When the user presses Next, the 'nextPage' value is sent in the .Read() with the other data, for example:
.Read(r => r.Action("GetItems", "Controller", new {
firstName = Model.FirstName,
getPage = 'eugwoiejg93239'
I understand that I can use the .Data() method to add my own data. However I am not sure how to change .Read to use a property of the return data (.Items) instead of using the data directly, so that I can include metadata for nextPage and previousPage. Also if I add this metadata, I am not sure how to store it (for example in a javascript function I can attach to .Data()).
Do you have any advice on how to do this?