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

Save Kendo Pagable User Input To Persist Grid State

1 Answer 59 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Raphael M.
Top achievements
Rank 1
Raphael M. asked on 18 Mar 2021, 08:48 AM

I'm having a problem with Kendo .Pagable. We have a webapplication that displays entries in a grid. The user can choose between 25, 50, 100, 200 entries per site. But whenever the user enters the entry edit page and goes back to the overview page it gets reset to 25 entries per page.

I could not find out how to persist the state (let's say 100 entries per page) for the grid on reload. Can you help me out?

Here the code snippet 

01.GRID.DataSource(dataSource => dataSource
02.          .Ajax()
03.          .PageSize(25)
04.          .Model(m => { m.Id(a => a.Id); })
05.          .Read(read => read
06.              .Action("Read", "Overview")
07.              .Data("additionalGridData"))
08.          .Sort(x => x.Add(y => y.Id))
09.      )
10.      .AutoBind(false)
11.      .Filterable()
12.      .Sortable(c=>c.SortMode(GridSortMode.MultipleColumn).AllowUnsort(true).ShowIndexes(true).Enabled(true))
13.      .Pageable(p => p.PageSizes(new[] {25, 50, 100, 200}))

Thanks in advance!

1 Answer, 1 is accepted

Sort by
0
Tsvetomir
Telerik team
answered on 23 Mar 2021, 06:43 AM

Hi Raphael,

By design, when the user leaves the page and then goes back, the page's life cycle starts over. Therefore, the grid will be initialized with the values that are within the cshtml file. 

In order to persist the options of the grid, you would have to include additional code. What I can recommend is that you follow the instructions from the following live demo:

https://demos.telerik.com/aspnet-core/grid/persist-state

Let me know if additional details are needed.

 

Kind regards,
Tsvetomir
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Grid
Asked by
Raphael M.
Top achievements
Rank 1
Answers by
Tsvetomir
Telerik team
Share this question
or