Grid Reset Button

Hello, im looking for a way to reset a grid settings to its initial state, after being grouped and sorted. I tried to delete the settings item from the page local storage and reloading the page but it is not working. This is my code
                 findingsGrid.enablePersistence = false;
                    if (window.localStorage.getItem("gridFindingsGrid"))
                        window.localStorage.removeItem("gridFindingsGrid");
                    document.location.reload();

Basically i want to remove all sorting and grouping from the columns.

1 Reply

VA Venkatesh Ayothi Raman Syncfusion Team July 2, 2018 12:50 PM UTC

Hi Kaloyan, 

Thanks for the update. 

As from your query, we suspect that do you want to clear the grid actions such as sorting, grouping and filtering. If so, we suggest you use following API and code example for clear the sorting and grouping, 

Code example
document.getElementById('btn').addEventListener("click", ()=>{ 
   
  
let len:number = grid.groupSettings.columns.length; 
let grpColumns: string[] = grid.groupSettings.columns; 
for(let i=0;i<len;i++){ 
    grid.ungroupColumn(grpColumns[i]); //clear the grouping 
  grid.clearSorting(); //clear the sorting 
 
   
   
} ) 

We have also prepared a sample for your convenience which can be download from following link, 

If we misunderstood your requirement, then could you please provide more information about your details? 

Regards, 
Venkatesh Ayothiraman. 


Loader.
Up arrow icon