In This Topic
The DataFilter control can be bound to any data-aware control or to a model/custom collection. You can choose to bind the control using any of the following ways:
Binding with data-aware control
When you bind the DataFilter control with a data-aware control, fields are generated. On the basis of these fields present in the data source, different filters are automatically generated in the DataFilter control. These filters are , , and . However, the filtering criteria are not generated with these filters, for example, no minimum and maximum values are generated for RangeFilter and empty checklist is generated for ChecklistFilter. So, you need to customize the auto generated filters for defining the filtering criteria using FilterAutoGenerating event of the class.
Model binding
- Define a class named 'Product' that returns the data which is to be bound to the DataFilter and DataGrid.
- Assign a data source to the DataGrid and C1DataFilter. Also, set AutoGenerateFilters property to true.
- To customize the auto generated filters for defining the filtering criteria such as the minimum or maximum values for the RangeFilter and the checklist items for the CheckListFilter, subscribe to the FilterAutoGenerating event of DataFilter class as shown in the following code. Also, add the following code in the event handler of the FilterAutoGenerating event which provides the checklist items for the two filters namely “Name”, “Color” and sets the maximum and minimum value for the price filter.
- To update the data of the data-aware control, subscribe to the FilterChanged event of DataFilter as shown in the following code. Add the following code in the event handler of the FilterChanged event which reassigns data source to the FlexGrid control through View property of the C1DataFilter class.
Back to Top