Grid persistence - Reset stored settings

Hello,
Is it possible to reset the stored settings of a grid with enabled persistence.
I want to add a reset button to the grid.

The problem with grid persistence is when you have multilanguage applications - the column names will not be switched between languages. Also if you update the application and add new columns - they will not appear.

Kind Regards
George Panayotov

3 Replies

DR Dhivya Rajendran Syncfusion Team June 29, 2018 12:59 PM UTC

Hi Georgi,
 
Thanks for contacting Syncfusion support.

Query : Is it possible to reset the stored settings of a grid with enabled persistence.
 
We have validated your query and you can reset the enable persistence settings of grid by using the way. In the below code example we have removed the columns property from the local storage of grid and set remaining items to the grid so that if you are add new columns in Grid then it store the new column value to the local storage. So we suggest you to use the below way to resolve the reported problem.
 
Kindly refer the below code snippet and sample for more information.
 
Index.ts
    var value = window.localStorage.getItem('gridGrid'); //"gridGrid" is component name + component id.
    var model = JSON.parse(value);
    delete model["columns"];    // remove the column from localStorage
    window.localStorage.setItem('gridGrid', JSON.stringify(model));
 
 
Note : Need to specify the above code before grid rendering.
 
Regards,
R.Dhivya



GP Georgi Panayotov June 29, 2018 04:07 PM UTC

Thanks for the reply.

Unfortunately the more i think the more complicated it gets.

Your solution will not work if i want to preserve the column visibility, grouping, filtering, etc
I can use the solution to change the caption - if i go through the model and remove only headerText. At this moment the only problem with the texts is with the Column chooser, on the table itself we are using headerTemplates and the translation works there. With modified solution i can solve the problem with texts only but not with new versions of our application.
(I didn't mention, but we are using the pure JavaScript controls in a ASP.Net Core app. - we've tried tag helpers, but liked more the JS approach)

Maybe i will need to add some version in the stored settings and on change to clear the settings...i will think about this before the next update.

If there is an event before store the settings - it can be used to remove some parts. Or options to specify what to save/load from persistence...

The persistence is great, but is not very usable in multilanguage applications or with applications with regular updates (out the box, with modifications will work great).

At this moment i will add a Reset button (not very user friendly solution) which will add a parameter and refreshes the page - on refresh i will  check for that parameter remove the settings (and the parameter itself)...

How can I store the grid settings in a object - is there a method for this?
If I take this object and the one, from the stored settings in the localStorage i can try to merge them on some conditions (changed language, new version,...).

Or is there a method to Rerender the grid - then on reset i can clear the stored parameters and rerender the grid?

Thanks,
George Panayotov



DR Dhivya Rajendran Syncfusion Team July 3, 2018 11:16 AM UTC


Hi Georgi, 

Thanks for your update. 

Before proceeding your query, could you please share the below details and it will be more helpful for further analysis and to provide a better solution as soon as possible. 

  1. You have mentioned you are using multi language application, How can you change the language by manual(Ex: dropdown change) or application level.
  2. Do you want to persist the grid state after changing the language or else it go for the initial state(Ex: If go from 1 to 2 page then change language in that case what is your expectation either display the at initial state(1 page) or the pagination(2 page) will be maintained after changing the language).  

Regards,
R.Dhivya 


Loader.
Up arrow icon