Reset all setting DataGrid

How can I reset via javascript the grid type filters sorting, paging, to the settings that occur immediately after opening the page

5 Replies

AG Ajith Govarthan Syncfusion Team March 13, 2020 01:29 PM UTC

Hi Krzysztof, 

Greetings from syncfusion. 

Query: Need to reset all the settings of the grid. 

Based on the query we have prepared a sample in that we have initial filtering and sorting and we will be clearing when the grid loads. We have used the created event of the grid in that we have called the clearFiltering, clearSorting, and cleared the paging by calling the goToPage method. We have shared the sample for your reference. 

Index.js 

        allowPaging: true, 
        allowFiltering: true, 
        allowSorting: true, 
           sortSettings: { columns: [{ field: 'OrderID', direction: 'Ascending' }, { field: 'ShipCity', direction: 'Descending' }] }, // initial sorting 
        filterSettings: { type: 'Menu', columns: [{ field: 'ShipCity', matchCase: false, operator: 'startswith', predicate: 'and', value: 'reims' } // initial filtering  
       ] }, 

        created:function(args){ 
          debugger; 
          this.clearSorting(); 
          this.clearFiltering(); 
          this.goToPage(1); 
        } 


Please get back to us if you need further assistance. 

Regards, 
Ajith G. 




KR Krzysztof March 16, 2020 11:11 AM UTC

It works very well. Thanks.

Can you also delete all grouping columns?


AG Ajith Govarthan Syncfusion Team March 17, 2020 08:45 AM UTC

Hi Krzysztof, 

Thanks for your update. 

Query: Can you also delete all grouping columns? 

To clear the grouping we suggest you to use clearGrouping method of EJ2 Grid. This method will clear all the grouped columns.  

We have shared the sample for your reference. 

Code Snippet: 
Index.js 

        allowPaging: true, 
        allowFiltering: true, 
        allowSorting: true, 
          groupSettings: { columns: ['OrderDate'] }, 
        created:function(args){ 
          this.clearGrouping(); 
          this.groupModule.renderGroupDropArea(); 
        } 



Please get back to us if you need further assistance. 

Regards, 
Ajith G. 




KR Krzysztof March 17, 2020 01:49 PM UTC

Thank you very much


AG Ajith Govarthan Syncfusion Team March 18, 2020 10:08 AM UTC

Hi Krzysztof , 

We are happy to hear that your issue has been resolved. 

Please get back to us if you need further assistance 

Regards, 
Ajith G. 



Loader.
Up arrow icon