Set Default Filter on a Column for Excel-Type Filtering

Hi,
I wonder if it's possible to set a default Filter on a column in a grid that uses excel-type Filtering when the page/grid is loaded?

For example: When the page is loaded, set a default filter for the "Date" column that shows the current date.

Here's my code:

<ejs-grid #grid [allowFiltering]='true' width=auto [dataSource]="ListValue" [frozenColumns]='4' [filterSettings]='filter' [toolbar]='toolbar' (toolbarClick)='toolbarClick($event)' [allowExcelExport]='true' >
          <e-columns>
            <e-column  [ngClass]="{'blue': (1==1)}" field='Machine' headerText='Máq.' width='230' isPrimaryKey="true" ></e-column>
            <e-column field='Code' headerText='Code' width='300'></e-column>
            <e-column field='Description' headerText='Description' width='300'></e-column>
            <e-column field='Date' headerText='Date' width='250'></e-column>
          </e-columns>
</ejs-grid>


public filter : FilterSettingsModel ={
    ignoreAccent: true,
    type:"Excel"
   }


1 Reply

TS Thiyagu Subramani Syncfusion Team April 24, 2020 08:19 AM UTC

Hi Edson, 

Thanks for contacting Syncfusion forum. 

We can achieve your requirement “Set Default Filter on a Column for Excel-Type Filtering” using filterSettings property. Using this property we have filtered column with current value when page/grid loaded. 

Please refer to the below code and sample link. 

this.filterSettings = { type: 'Excel',  columns: [ 
            { field: 'OrderDate', matchCase: false, operator: 'equal', predicate: 'or', value: new Date() }] }; 





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

Regards, 
Thiyagu S 


Loader.
Up arrow icon