0

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

GRID.DataSource(dataSource => dataSource
          .Ajax()
          .PageSize(25)
          .Model(m => { m.Id(a => a.Id); })
          .Read(read => read
              .Action("Read", "Overview")
              .Data("additionalGridData"))
          .Sort(x => x.Add(y => y.Id))
      )
      .AutoBind(false)
      .Filterable()
      .Sortable(c=>c.SortMode(GridSortMode.MultipleColumn).AllowUnsort(true).ShowIndexes(true).Enabled(true))
      .Pageable(p => p.PageSizes(new[] {25, 50, 100, 200}))

Thanks in advance!

1 Answers1

0

Save grid options in localStorage on edit or on window.onbeforeunload then load options and set it on grid. This is an example with jQuery, but it is the same approach for other languages.

//save
let options = $('#grid').getKendoGrid().getOptions();
localStorage['grid-options'] = kendo.stringify(options);

//load
let options = localStorage['grid-options'];
let optionsObject = JSON.parse(options);
$('#grid').getKendoGrid().setOptions(optionsObject);

This will save page size, current page, and other things.

dev_in_progress
  • 2,484
  • 2
  • 21
  • 32
  • Seems like dataSource.PageSize overwrites options on load of the grid. But if not set the default size is 10...which is not an pageable option – Raphael Müller Mar 25 '21 at 10:15