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

Grid Auto Persist Not refreshing columns between user roles

1 Answer 10 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Logan
Top achievements
Rank 1
Veteran
Logan asked on 01 Feb 2019, 06:24 PM

We have a grid that has different columns for different user roles. We have a requirement to persist filters. The problem we are running into is that user A is an admin and sees their specified columns and logs out, user B who is not an admin on the same computer is seeing the admin columns instead of the columns they are supposed to see. Is there any way to just persist filters?

The secondary problem is when we publish updates to the website the grid does not reflect our changes due to the persistence. This could be a serious problem. 

 

We are using:

$(document).ready(function () {
    $("div[data-role='grid']").each(function (index, element) {
        var grid = $(element).data("kendoGrid");
        var key = location.pathname + '-' + element.id;
        var options = localStorage[key];
        if (options)
        {
            grid.setOptions(JSON.parse(options));
        }
        grid.dataSource.read();

    })

})

$(window).on('beforeunload', function () {
    $("div[data-role='grid']").each(function (index, element) {
        var grid = $(element).data("kendoGrid");
        var key = location.pathname + '-' + element.id;
        localStorage[key] = kendo.stringify(grid.getOptions(grid.getOptions());
    })
})

 

 

 

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 06 Feb 2019, 12:36 PM
Hi Logan,

One option for resolving the issue would be to add some user identifier in the local storage or you could use the Grid's column collection as shown below:
var grid = $(element).data("kendoGrid");
var key = location.pathname + '-' + element.id;
var options = localStorage[key];
if (options)
{
      options = JSON.parse(options);
    options.columns = grid.getOptions().columns;
    grid.setOptions(options);
}

As for the other problem, if the Grid is bound to remote data, once the options are restored, the Grid should be populated with the new data. If that problem persists, please share the configuration of the Grid.


Regards,
Konstantin Dikov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Logan
Top achievements
Rank 1
Veteran
Answers by
Konstantin Dikov
Telerik team
Share this question
or