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
valueChange
event of the TextBox component.<kendo-textbox (valueChange)="filterAll($event)" ...></kendo-textbox>
-
In the event handler, create a custom
CompositeFilterDescriptor
for the columns that need to be filtered and update the Grid'sfilter
property.filterAll(inputValue) { this.state.filter = { logic: 'or', filters: [{ field: 'ProductName', operator: 'contains', value: inputValue, }, ...], }; }
-
Use a custom
rebind
function to pass the current GridState
to a dedicated data service method that returns the updated collection.In this case, the
ProductsService
extends theNorthwindService
which has aquery
method that is responsible for the communication with the remote server. Thequery
method passes the information required for server-side data operations like filtering, sorting, and others.@ViewChild(ProductsBindingDirective) public dataBinding: ProductsBindingDirective; filterAll(inputValue) { this.state.filter = { ... }; this.dataBinding.rebind(); }
public 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.