This demo illustrates how to add a filter bar to the grid.
Enabling the Filter
Filters can be enabled by the ShowFilterBar and AllowFilter properties. The AllowFilter can be set for those columns that require filter options.
// ShowFilterBar for the Main table.
this.gridGroupingControl1.TopLevelGroupOptions.ShowFilterBar = true;
//Change the appearance of the Filter Row.
this.gridGroupingControl1.TableDescriptor.Appearance.FilterBarCell.BackColor = Color.AliceBlue;
//Enable the Filter for each Column.
for(int i = 0 ; i< gridGroupingControl1.TableDescriptor.Columns.Count;i++ )
gridGroupingControl1.TableDescriptor.Columns[i].AllowFilter = true;
Features
With TopLevelGroupOptions, the filter bar can be added to the top level group.
this.gridGroupingControl1.TopLevelGroupOptions.ShowFilterBar = true;
With ChildGroupOptions, the filter bar can be added to the child groups.
this.gridGroupingControl1.ChildGroupOptions.ShowFilterBar = true;
With NestedTableGroupOptions, the filter bar can be added to the nested tables.
this.gridGroupingControl1.NestedTableGroupOptions.ShowFilterBar = true;
Two New Events are added to improve the functionality of the filter.
Events
FilterBarSelectedItemChanging
FilterBarSelectedItemChanged
Cancel Filter From Column feature provides option to cancel the filter from a particular column.
Code to cancel the filter:
void gridGroupingControl1_FilterBarSelectedItemChanging(object sender, FilterBarSelectedItemChangingEventArgs e)
{
object item = comboBox1.SelectedItem;
if (e.Column.Name == item.ToString())
{
e.Cancel = true;
}
else
{
e.Cancel = false;
}
}
It is possible to filter based on the selected index and selected text.
Code to get the selected index and seleced text:
void gridGroupingControl1_FilterBarSelectedItemChanged(object sender, FilterBarSelectedItemChangedEventArgs e)
{
label3.Text = e.SelectedIndex.ToString();
label5.Text = e.SelectedText.ToString();
}