This topic demonstrates how to enable the Excel-Style Filtering feature of the WebDataGrid™ control.
The following topics are prerequisites to understanding this topic:
This topic contains the following sections:
By default, in WebDataGrid , the standard (non-Excel type) of filtering is enabled. Excel-Style Filtering option is enabled by setting the WebDataGrid ’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 sections demonstrate how to enable Excel-Style Filtering on all columns except one and disable filtering for that one column:
The following table maps the desired filtering behavior to the property settings that configure it:
This example demonstrates how to enable Excel-Style Filtering on all columns except one (ContactName) and disable filtering for that one column using the Designer.
The following screenshot is a preview of the final result:
To complete this procedure, you need to the following:
An ASP.NET Web Project with a WebDataGrid instantiated in a web page
The WebDataGrid bound to a SqlDataSource component and configured to retrieve the CustomerID , CompanyName , ContactName , and ContactTitle fields from the Customers table of the Northwind sample database. (For details, see the Getting Started with WebDataGrid topic.)
Following is a conceptual overview of the process:
1. Enabling Excel-Style Filtering
2. Disabling Filtering on one column
3. (Optional) Verifying the result
The following steps demonstrate how to enable the Excel-Style Filtering feature for the WebDataGrid and how to disable filtering for the ContactName column.
1. Launch the Behaviors Editor Dialog.
Click on the smart tag of the WebDataGrid and then select the Edit Behaviors option .
The WebDataGrid Designer dialog opens up.
2. Enable Filtering.*
In the WebDataGrid Designer dialog, in the left-hand side panel, check Filtering.
In the right-hand side panel, set the FilterType property to ExcelStyleFilter.
Click the Apply button .
1. Add a new column.
Launch the Column Setting dialog.
With the Filtering box in the left pane checked, locate the ColumnSettings property and click the ellipsis (…) button .
The Column Setting dialog opens up.
Add a new column setting.
In the left-hand side pane, click the add item option . The new column setting appears in the column settings collection.
In the right-hand side pane, from the ColumnKey drop-down, select Add/Modify Columns.
The Edit Grid Columns dialog opens up.
Define the ContactName column.
In the Edit Grid Columns dialog, from the Available Fields panel, select BoundField.
Click on the Add Field button. The newly added field appears in the Selected Fields panel. (By default, its name is BoundColumn_0 .)
From the Selected Fields panel, select the column which was just added.
In the right-hand side pane, set the DataFieldName property to ContactName .
In the right-hand side pane, set the Key property to ContactName .
Click OK to commit.
Assign the newly created column to the ColumnKey property.
From the ColumnKey drop-down, select the ContactName column .
2. Disable*filtering for the new column.
Set the Enabled property to False and then click OK to commit.
To verify the result, save and run the project, then test the filtering behavior of the WebDataGrid .
This example demonstrates how to enable Excel-Style Filtering on all columns except one (ContactName) and disable filtering for that one column in the ASPX markup.
In ASPX:
<Behaviors>
<ig:Filtering FilterType="ExcelStyleFilter">
<ColumnSettings>
<ig:ColumnFilteringSetting ColumnKey="ContactName" Enabled=" />
</ColumnSettings>
</ig:Filtering>
</Behaviors>
This example demonstrates how to enable Excel-Style Filtering on all columns except one (ContactName) and disable filtering for that one column in the code behind.
This code snippet must be inserted into the Page_Load
event of the ASP.NET web page.
In C#:
//Create a Filtering Behavior
this.WebDataGrid2.Behaviors.CreateBehavior<Filtering>();
//Set Filtering Behavior to Excel Style Filter
this.WebDataGrid2.Behaviors.Filtering.FilterType = Infragistics.Web.UI.GridControls.FilteringType.ExcelStyleFilter;
//Create a ColumnFilteringSetting
ColumnFilteringSetting settingColumn = new ColumnFilteringSetting();
//Set the ColumnKey
settingColumn.ColumnKey = "ContactName";
//Set Enabled property to false
settingColumn.Enabled = false;
//Add the created ColumnSetting
this.WebDataGrid2.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.