Add params for filtering in Angular Grid component
17 Sep 20253 minutes to read
Customize the default filter UI in the Syncfusion Angular Grid by configuring the params
property within a column’s filter settings. This allows fine control over the filtering component’s behavior and appearance, especially in Menu filter mode.
For instance, the sample below demonstrates columns OrderID and Freight as numeric types. When the filter dialog is opened for these columns, a NumericTextBox appears by default with a spin button for numeric value adjustment. By assigning options to the params
property, such as setting showSpinButton
to false, you can hide the spin button in the NumericTextBox for the OrderID column, customizing the user interface as required.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { GridModule, FilterService, PageService} from '@syncfusion/ej2-angular-grids'
import { MultiSelectModule, CheckBoxSelectionService,DropDownListAllModule } from '@syncfusion/ej2-angular-dropdowns'
import { CheckBoxModule } from '@syncfusion/ej2-angular-buttons'
import { Component, OnInit } from '@angular/core';
import { data } from './datasource';
import { FilterSettingsModel } from '@syncfusion/ej2-angular-grids';
@Component({
imports: [
GridModule,
MultiSelectModule,
DropDownListAllModule,
CheckBoxModule
],
providers: [FilterService, PageService,CheckBoxSelectionService],
standalone: true,
selector: 'app-root',
template: `<ejs-grid [dataSource]='data' [allowFiltering]='true' [allowPaging]='true' [filterSettings]='filterOption'>
<e-columns>
<e-column field='OrderID' headerText='Order ID' [filter]='filterParams' textAlign='Right' width=90></e-column>
<e-column field='CustomerID' headerText='Name' width=140></e-column>
<e-column field='ShipName' headerText='ShipName' width=140></e-column>
<e-column field='Freight' headerText='Freight' textAlign='Right' format='C2' width=90></e-column>
</e-columns>
</ejs-grid>`
})
export class AppComponent implements OnInit {
public data?: object[];
public filterParams?: object;
public filterOption?: FilterSettingsModel = { type: 'Menu'};
public height = '220px';
ngOnInit(): void {
this.data = data;
this.filterParams = { params: { showSpinButton: false } };
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));