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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Thread ID:

Created:

Updated:

Platform:

Replies:

143291 Mar 13,2019 05:02 AM UTC Mar 13,2019 09:51 AM UTC ASP.NET Core - EJ 2 1
loading
Tags: DataGrid
Omprakash Yadav
Asked On March 13, 2019 05:02 AM UTC

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

Thavasianand Sankaranarayanan [Syncfusion]
Replied On 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. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon