Clear filter data without refreshing dataSource

Hello,

is there a possibility to clear (programatically) filtering and/or sorting from my grid and do not call my method WebAPI method to get new data?

I am trying to do it with grid clearFiltering() and clearSorting() methods but after doing it I am getting by default request to my webApi to get new data.

3 Replies

DR Dhivya Rajendran Syncfusion Team February 24, 2020 07:22 AM UTC

Hi AC, 

Thanks for contacting Syncfusion support. 

By default, while using remote data binding, all grid actions such as paging, sorting(clear sorting), editing, grouping, filtering(clear filtering), etc., will be processed on server-side. To avoid post back for every action you can set offline as true. It will get the whole data in Initial Rendering itself and it will avoid post back each time when perform the grid actions. 


Please get back to us, If you need further assistance. 

Regards, 
R.Dhivya 



UN Unknown Syncfusion Team February 24, 2020 11:54 AM UTC

Hello,


I tried to set offline just before clearing filters but in that case I am getting error Cannot read property 'pvtData' of undefined. Maybe I am doing something wrong?

I am doing it like this:

public myGrid: GridComponent;

<some code here>
this.myGrid.dataSource['dataSource'].offline = true;
this.myGrid.clearFiltering();
<some code here>

After this operation in my console window I can see error:


I have tried to reinstall packages but it still causes same error (I am using ej2-data version 17.1.47).

I am doing it like that because only in this case I do not need to re-render my grid data but in other cases I must again get data from WebAPI.


DR Dhivya Rajendran Syncfusion Team February 25, 2020 11:19 AM UTC

Hi AC, 

Thanks for your update. 

We would like to inform that this is not a package related issue because when we dynamically change offline property in data manger then it cause the problem so we suggest you to enable Offline property at initialization of Data Manger itself. 

As per our default behavior, when we done any actions in grid it will send the server request to get the data from server in web api adaptor.  

If you want to make request based on your condition then please refer the below documentation to bind the datasource to Grid from external ajax request. 


Please get back to us, if you need further assistance. 

Regards, 
R.Dhivya 


Loader.
Up arrow icon