How to reset all filter, group, sorter, resizinig changed by user?

Hello,

I would like to put a button that when clicked by the user, all changes to filters, groupings, resizes, hidden columns, sorter and leave the datagrid in the default when it was opened for the first time.


I tried to remove the locally stored variable

             localStorage.removeItem('gridGrid') and then applied a grid.refresh() and it didn't work. The filters still continued;


i am using enablePersistence="true"




3 Replies 1 reply marked as answer

SI Santhosh Iruthayaraj Syncfusion Team June 28, 2023 02:30 PM UTC

Hi Roberto,


Greetings from Syncfusion support.


You can reset the Grid to its initial state by following the below steps,


  1. Firstly, make sure to disable the enablePersistence property of the Grid.
  2. Next, you need to clear the local storage data associated with the Grid.
  3. Finally, destroy the Grid instance and reload the page.


Here's a code snippet that demonstrates how you can achieve this:


[CSHTML]

 

<ejs-grid id="Grid" dataSource="@order" allowPaging="true" enablePersistence='true'>

.  .  .  .  .

</ejs-grid>

<button onclick="onResetBtnClick()">Reset Grid</button>

 

 

function onResetBtnClick() {

let grid = document.getElementById('Grid').ej2_instances[0];

grid.enablePersistence = false;

window.localStorage.removeItem('gridGrid');

grid.destroy();

location.reload();

}

 


For detailed information, you can refer to our documentation on resetting the Grid to its initial state:


Documentation: https://ej2.syncfusion.com/aspnetcore/documentation/grid/state-persistence/state-persistence#restore-initial-grid-state


I hope this solution addresses your concern. If you have any further queries or need additional assistance, please let us know.


Regards,

Santhosh I


Marked as answer

RO Roberto June 28, 2023 10:16 PM UTC

Perfect!!



SG Suganya Gopinath Syncfusion Team July 1, 2023 01:47 PM UTC

We are glad that the provided solution helped to solve the issue. Please get back to us for further assistance. 


Loader.
Up arrow icon