We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Want to save Grid column filters in database so that user can create several filters and then apply then by clicking pre saved filters

Hi,
I want to use your grid control but i have a question.

I have a very large lead table and i want a facility in your grid to create several column filters on grid and save then in database.
So next time when i come i need not to do the filter selection i can just select a pre saved filter and it should be applied on grid.

here is your example link on which i want to do this

https://aspdotnetcore.syncfusion.com/Grid/GridOverview?_ga=2.115592704.708597701.1552385078-204344173.1550393109#/material

1) Save selected filter criteria in database for future use
2) User can able to select from pre saved filters and on this grid must be filtered.

Thanks

1 Reply

TS Thavasianand Sankaranarayanan Syncfusion Team March 13, 2019 09:51 AM UTC

Hi Omprakash, 

Greetings from Syncfusion. 

We have analyzed your requirement. We suggest you to use the “actionBegin” event and “filterByColumn” method of Grid. In the “actionBegin” event handler we will be getting the “currentFilterObject” with “requestType” as “filtering” each time you perform filtering in Grid. You can push this  “currentFilterObject” into an array of object variable or save this to a  database. Then you can perform filter with this pre-saved values by using the “filterByColumn” method. 

Documentation :  
 
To demonstrate the above provided logic, we have prepared a sample. In the below sample, we will be saving the “currentFilterObject” in the “actionBegin” handler to an object variable(ddldata), which will be assigned to a “DropDownList” component. So now each time you perform filtering in Grid, the drop down list will be populated with the “currentFilterObject”. Now the drop down list will be containing the pre-saved filter values. In the change event of dropdown list we will be calling the “filterByColumn” method with arguments provided based on the value selected from the drop down. Please refer the sample link below, 

[html] 
 
    <ejs-dropdownlist #ddl [dataSource]='ddldata' value='Menu' [fields]='ddlfields' (change)="onChange($event)"></ejs-dropdownlist> 
 
    <ejs-grid #grid [dataSource]='data' allowPaging='true' allowFiltering='true'... (actionBegin)="begin($event)" [filterSettings]='filterSettings'> 
        ... 
    </ejs-grid> 
 
[ts] 
 
    public ddlfields: Object = { text: 'filtertime' }; 
    ... 
    public onChange(e: any): void { 
        this.grid.filterModule.filterByColumn(this.ddlinstance.dataSource[e.value].field,this.ddlinstance.dataSource[e.value].operator, 
                                              this.ddlinstance.dataSource[e.value].value);    //Call the filterByColumn method with arguments based on the value selected from dropdown. 
    }  
    begin(args){ 
      if(args.requestType == "filtering" && (document.activeElement as any).innerText != "CLEAR"){ 
        args.currentFilterObject.filtertime = this.ddldata.length;      //Assigning priority in pre-saved filters(this will be displayed in drop down list) 
        this.ddldata.push(args.currentFilterObject); 
        this.ddlinstance.refresh()               //Refresh the drop down list component to update the drop down list data 
      } 
    } 
 

Please get back to us if you need further assistance. 

Regards, 
Thavasianand S. 


Loader.
Live Chat Icon For mobile
Up arrow icon