This demo illustrates the addition of a filter bar to a simple GridDataBoundGrid control.
A filter bar is a row of combo boxes displayed at the top of the grid that allow you to filter the grid by selecting items from the combo boxes. The combo box entries are generated from the unique values in the column. You can also perform complex filtering through a custom filter dialog box. In addition, you can use a custom filter dialog box to implement localized dialog boxes.
Features:
Passing the grid through the WireGrid method to an instance of the GridFilterBar creates a filter bar to the row below the column header.
GridFilterBar theFilterBar = new GridFilterBar(); theFilterBar.WireGrid(this.gridDataBoundGrid1);
To turn off unwanted filter headers, you must handle the CreatingColumnHeader event of the grid filter bar.
Use the RowFilter property to get and set the filter criteria.
By default, the top two strings in the filter drop-down are "none" and "custom". To change this, set GridFilterBarStrings property of the respective strings to empty as follows.
theFilterBar.GridFilterBarStrings[0] = ""; theFilterBar.GridFilterBarStrings[1] = "";
The rest of the string comes under the custom row filter dialog box. This makes it easier to change the language on display.
The FilterBarShowDialog handler is used to generate localized dialog boxes instead of built-in custom dialog boxes.
theFilterBar.FilterBarShowDialog += new GridFilterBarShowDialogEventHandler(GridFilterBarShowDialogEventHandler);
TheFilterCriteria property of the FilterBarShowDialog event can be used to set the filter.
The filter bar can be removed by unwiring as follows. It supports the data table and the data view.
theFilterBar.UnWireGrid();