Hello, Aaron,
I have logged a task for the team to update the getOptions() method API with a note that describes the behaviour. I meant that the current behaviour needs to be documented. I did not intend to imply that this is a bug that needs to be fixed.
Currently, most of the team is away for the holiday season, however, I can address the question of whether we intend to change the behaviour in future releases at the beginning of next year.
Regarding the page, it seems to occur when the applyFilter() method is called. I debugged the suggestion and was able to simplify it and improve it in such way that the state is restored for both the filter and the grid, including the page:
function saveOptions() {
var grid = $("#grid").getKendoGrid();
var options = grid.getOptions();
localStorage["persistedOptions"] = kendo.stringify(options);
localStorage["dsQuery"] = kendo.stringify({
filter: dataSource1.filter(),
page: dataSource1.page(),
pageSize: dataSource1.pageSize(),
aggregate: dataSource1.aggregate(),
sort: dataSource1.sort(),
group: dataSource1.group()
});
alert("Saved");
}
function restoreOptions() {
var grid = $("#grid").getKendoGrid();
var filter = $('#filter').getKendoFilter();
var options = JSON.parse(localStorage["persistedOptions"]);
var dsQuery = JSON.parse(localStorage["dsQuery"]);
dataSource1.query(dsQuery);
options.dataSource = dataSource1;
grid.setOptions(options);
filter.setOptions({
expression: dataSource1.filter()
});
alert("Restored");
}
Steps to test:
- Using the Filter control, add "ShipName contains 2"
- Click "Apply"
- Go to page 2 in the grid
- Click "Save Options"
- Refresh the page
- Click "Restore Options"
Finally, for the question of whether we need to save the data source options - if we want to persist the data source query - page, filter, group, sort, etc. then yes, we need to save the options that we want to use as with the current behaviour they disappear.
I hope this helps.
Regards,
Alex Hajigeorgieva
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.