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

persisting grid state

1 Answer 15 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bruno
Top achievements
Rank 1
Bruno asked on 15 Feb 2021, 10:05 AM

Hi,

I have implemented a Telerik grid and I managed to store the filtering and sorting in our database for each person that uses it.
So every time a user navigates to that screen, his personal filters are already applied to the grid.

However, in one scenario this does not work...

In my grid every row contains a link to another page.
Now if someone navigates to the other page from a link in the grid, and then he clicks the 'go back' button from the browser, the filters are disappeared.
(Unless he refreshes the page another time, then the new filters appear again).

How can I avoid the filters from disappearing when navigating away from the page from a link in the grid?

Kind regards,

Bruno

1 Answer, 1 is accepted

Sort by
0
Patrick | Senior Technical Support Engineer
Telerik team
answered on 16 Feb 2021, 03:57 PM

Hi Bruno,

There are a couple of options in which you could take if a user clicks on a link within the Grid.  

1.  In the hyperlink, include target="_blank" to open the page in a new window or tab.  This will keep the Grid on a separate page and will remove the need to click the go back button.

2.  During the window's onload event, determine if there are any grid options saved.  If so, when the page goes back, the options will load for the Kendo UI Grid.

    $(document).ready( function () {

        window.onload = function () {

            //Reference the Grid
            var grid = $("#grid").data("kendoGrid");

            //for simplicity, this used localStorage
            var options = localStorage["kendo-grid-options"];
            
            //if the options exist, set the Grid Options
            if (options) {
                grid.setOptions(JSON.parse(options));
            }
        };
    });

An example of persisting the state of the Kendo UI Grid can be found in our live demos.

Regards,
Patrick
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/.

Tags
Grid
Asked by
Bruno
Top achievements
Rank 1
Answers by
Patrick | Senior Technical Support Engineer
Telerik team
Share this question
or