Filtering all Grid Columns when Using a Remote-Binding Directive
Environment
| Product | Progress® Kendo UI® for Angular Data Grid |
Description
How can I filter the columns of the Data Grid when using a Remote-Binding Directive?
Solution
By default, the Kendo UI for Angular Data Grid component allows you to filter each of its columns separately by applying various filtering conditions.
To filter all or multiple columns of the Data Grid by adding an external TextBox component when you use a remote-binding directive:
-
Handle the built-in
valueChangeevent of the TextBox component.html<kendo-textbox (valueChange)="filterAll($event)" ...></kendo-textbox> -
In the event handler, create a custom
CompositeFilterDescriptorfor the columns that need to be filtered and update the Grid'sfilterproperty.tsfilterAll(inputValue) { this.state.filter = { logic: 'or', filters: [{ field: 'ProductName', operator: 'contains', value: inputValue, }, ...], }; } -
Use a custom
rebindfunction to pass the current GridStateto a dedicated data service method that returns the updated collection.In this case, the
ProductsServiceextends theNorthwindServicewhich has aquerymethod that is responsible for the communication with the remote server. Thequerymethod passes the information required for server-side data operations like filtering, sorting, and others.ts@ViewChild(ProductsBindingDirective) public dataBinding: ProductsBindingDirective; filterAll(inputValue) { this.state.filter = { ... }; this.dataBinding.rebind(); }tspublic rebind(): void { this.productsService.query(this.state); }
The following example demonstrates how to filter all Grid columns from an outer input field when using a remote-binding directive.