Filtering allows you to view particular records based on filter criteria. To enable filtering in the Grid, set the AllowFiltering to true. Filtering options can be configured through FilterSettings.
You can apply and clear filtering by using filterByColumn and clearFiltering methods.
To disable filtering for a particular column, set Columns.AllowFiltering to false.
To apply the filter at initial rendering, set the filter Predicate object in FilterSettings.Columns.
The filter operator for a column can be defined in the FilterSettings.Columns.Operator property.
By default, the FilterSettings.Columns.Operator value is equal.
By setting the AllowFiltering to true, the filter bar row will render next to the header, which allows you to filter data. You can filter the records with different expressions depending upon the column type.
You can enter the following filter expressions (operators) manually in the filter bar.
The [filterBarTemplate] is used to add a custom component for a particular column and this contains the following functions.
create – It is used for creating custom components.
read – It is used to read the Filter value selected.
write - It is used to wire events for custom components.
In the following sample dropdown is used as custom component in EmployeeID column.
You can change the default filter operator by extending filterModule.filterOperators property in DataBound event. In the following sample, we have changed the default operator for string typed columns as contains from startsWith.
You can enable filter menu by setting the FilterSettings.Type as Menu. The filter menu UI will be rendered based on its column type, which allows you to filter data. You can filter the records with different operators.
AllowFiltering must be set as true to enable filter menu.
Setting Columns.AllowFiltering as false will prevent filter menu rendering for a particular column.
You can use both Menu and CheckBox filter in a same Grid. To do so, set the Column.Filter.Type as Menu or CheckBox.
In the following sample menu filter is enabled by default and checkbox filter is enabled for the CustomerID column using the Column.Filter.Type.
You can enable Excel like filter by defining. FilterSettings.Type as Excel.The excel menu contains an option such as Sorting, Clear filter, Sub menu for advanced filtering.