New to Telerik UI for ASP.NET Core? Download free 30-day trial

State Persistence

The Grid enables you to save the custom settings of the user and restore them after the user logs back at some future moment.

To persist the settings that were previously applied to its structure, use the getOptions() and setOptions() methods of the Grid. These methods allow you to serialize the current state of the Grid if needed and recover that state later. For a runnable example, refer to the demo on persisting the state of the Grid.

By design, the getOptions() method retrieves the current Grid settings along with the current state of the DataSource options. To restore particular Grid or DataSource options, you can extract only the desired options from the object returned by getOptions().

The example below shows how to retrieve and set the options of the Grid columns.

    let grid = $("#grid").data("kendoGrid"); // Get a reference to the Grid.
    let currentOptions = grid.getOptions(); // Get the current Grid options and DataSource state.
    let columnOptionsForSaving = kendo.stringify(currentOptions.columns); // Extract the Grid columns options.
    grid.setOptions({ columns: JSON.parse(columnOptionsForSaving)}); // Call the "setOptions()" method to apply the stored column options of the Grid.

See Also

In this article