This is a migrated thread and some comments may be shown as answers.

Returning metadata from .Read() and using it

1 Answer 131 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Phil
Top achievements
Rank 1
Phil asked on 02 Feb 2017, 09:01 AM

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?

1 Answer, 1 is accepted

Sort by
0
Phil
Top achievements
Rank 1
answered on 03 Feb 2017, 03:57 PM

I posted this question on StackOverflow and it has been answered.

http://stackoverflow.com/questions/42021296/returning-metadata-from-read-and-using-it-in-a-kendo-grid/42026553#42026553

Tags
Grid
Asked by
Phil
Top achievements
Rank 1
Answers by
Phil
Top achievements
Rank 1
Share this question
or