This topic demonstrates how to enable the Excel-Style Filtering feature of the WebHierarchicalDataGrid™ control.
The following topics are prerequisites to understanding this topic:
This topic contains the following sections:
By default, in WebHierarchicalDataGrid , the standard (non-Excel type) of filtering is enabled. Excel-Style Filtering option is enabled by setting the WebHierarchicalDataGrid ’s FilterType property to ExcelStyleFilter . This enables Excel-Style Filtering on all columns, but you can use the ColumnFilteringSetting property to disable the feature on per-column basis.
The following section demonstrates how to enable Excel-Style Filtering on all columns:
The following sections demonstrate how to enable Excel-Style Filtering on all columns except one column in the parent band and one column in the parent band disable filtering for those two columns:
The following table maps the desired filtering behavior to the property settings that configure it:
This example demonstrates how to enable the Excel-Style Filtering feature of the WebHierarchicalDataGrid for both the parent and the child bands using the Designer.
The following screenshot is a preview of the final result:
To complete the procedure, you need the following:
An ASP.NET Web Project with a WebHierarchicalDataGrid instantiated in a web page
The WebHierarchicalDataGrid bound to the WebHierarchicalDataSource component using the Northwind Categories and Products tables. (For details, see the * Getting Started with WebHierarchicalDataGrid* topic.)
Following is a conceptual overview of the process: 1. Enabling Excel-Style Filtering
2. (Optional) * Verifying the result*
The following steps demonstrate how to Enable Excel-Style Filtering using the Designer.
1. Launch the Edit Grid Behaviors dialog.
Click on the smart tag of the WebHierarchicalDataGrid and then select the Edit Behaviors option .
The WebDataGrid Designer dialog opens up. 2. Enable Excel-Style Filtering on both the parent and child levels.
In the Edit Grid Behaviors dialog. dialog, in the left-hand side panel, check Filtering .
In the right-hand side panel, set the * FilterType* property to ExcelStyleFilter .
In the right-hand side panel, set the EnableInheritance property to True .
These settings enable filtering and allow it for the child bands.
Click the OK button .
To verify the result, save and run the project, then test the filtering behavior of the WebHierarchicalDataGrid .
This example demonstrates how, in the ASPX markup, to enable Excel-Style Filtering on all columns for both the parent and the child bands except on one column in each band (CategoryName in the parent band and ProductName in the child band) for which filtering is explicitly disabled.
The following picture demonstrates the result generated by the code in this example.
In ASPX:
<Behaviors>
<ig:Filtering FilterType="ExcelStyleFilter">
<ColumnSettings>
<ig:ColumnFilteringSetting ColumnKey="CategoryName" Enabled=" />
</ColumnSettings>
</ig:Filtering>
</Behaviors>
<Bands>
<ig:Band Key="Products" DataMember="SQLDataSource_Products" DataKeyFields="CategoryID">
<Behaviors>
<ig:Filtering FilterType="ExcelStyleFilter">
<ColumnSettings>
<ig:ColumnFilteringSetting ColumnKey="ProductName" Enabled=" />
</ColumnSettings>
</ig:Filtering>
</Behaviors>
</ig:Band>
</Bands>
This example demonstrates how, in the ASPX markup, to enable Excel-Style Filtering on all columns for both the parent and the child bands except on one column in each band (CategoryName in the parent band and ProductName in the child band) for which filtering is explicitly disabled.
The following picture demonstrates the result generated by the code in this example.
In C#:
protected void Page_Load(object sender, EventArgs e)
{
this.WebHierarchicalDataGrid1.InitializeBand += new InitializeBandEventHandler(WebHierarchicalDataGrid1_InitializeBand);
this.WebHierarchicalDataGrid1.Behaviors.CreateBehavior<Filtering>();
this.WebHierarchicalDataGrid1.Behaviors.Filtering.FilterType = FilteringType.ExcelStyleFilter;
this.WebHierarchicalDataGrid1.Behaviors.Filtering.EnableInheritance = true;
//Create a ColumnFilteringSetting
ColumnFilteringSetting settingColumn = new ColumnFilteringSetting();
//Set the ColumnKey
settingColumn.ColumnKey = "CategoryName";
//Set the Enabled property to false
settingColumn.Enabled = false;
this.WebHierarchicalDataGrid1.Behaviors.Filtering.ColumnSettings.Add(settingColumn);
this.WebHierarchicalDataGrid1.RefreshBehaviors();
}
void WebHierarchicalDataGrid1_InitializeBand(object sender, BandEventArgs e)
{
e.Band.Behaviors.CreateBehavior<Filtering>();
e.Band.Behaviors.Filtering.Enabled = true;
e.Band.Behaviors.Filtering.FilterType = FilteringType.ExcelStyleFilter;
e.Band.Behaviors.Filtering.EnableInheritance = true;
ColumnFilteringSetting settingColumn = new ColumnFilteringSetting();
settingColumn.ColumnKey = "ProductName";
settingColumn.Enabled = false;
e.Band.Behaviors.Filtering.ColumnSettings.Add(settingColumn);
}
The following topics provide additional information related to this topic:
The following samples provide additional information related to this topic: