This topic explains how to configure the Excel-Style Filtering options of the WebDataGrid™ control.
The following topics are prerequisites to understanding this topic:
This topic contains the following sections:
Configuring the Capitalization of the Unique Values in the Filtering Drop-Down
Configuring the capitalization of unique values using the Designer
Configuring the capitalization of unique values in the ASPX markup
Configuring the capitalization of unique values in the code-behind
Configuring the Text for the Null Values in the Filtering Drop-Down
The following table lists the configurable aspects of the Excel-Style Filtering feature of the WebDataGrid control.
The capitalization options for the unique values are the following:
Lowercase capitalization (default) – the items appear in lowercase letters
Uppercase capitalization – the items appear in uppercase letters (all caps)
Camelcase capitalization – the items appear with sentence capitalization (Only the first letter of the item is capitalized even if the item consists of more than one words.)
The capitalization is managed by the UniqueValueCasing property.
The capitalization of unique values can be set on two levels – per column and for the whole grid depending on whether the respective property of the grid or of the column is being set. The column setting takes priority.
The following table maps the desired capitalization configurations of the property settings that configure them:
To complete the procedure, you need the following:
An ASP.NET Web project with a WebDataGrid instantiated on 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.)
To set the UniqueValueCasing property to Camel on grid-level using the designer:
1. From the smart tag of the WebDataGrid , open the WebDataGrid Designer.
2. In the left pane, select the desired filtering behavior.
3. In the right pane, set the UniqueValueCasing property to Camel .
4. Click the OK button.
For the purpose of this example, the setting will be applied to a column with the key ContactName . The procedure assumes that the ContactName column has been added in advance. For information on how to add the column, see the Enabling Excel-Style Filtering (WebDataGrid) topic.
To set the UniqueValueCasing property to Camel on the column level:
1. From the smart tag of the WebDataGrid , open the WebDataGrid Designer.
2. In the left pane, select the desired filtering behavior.
3. In the left pane, locate the ColumnSettings property and click the ellipsis (…) button. The Column Setting dialog opens up.
In the column setting, from the drop-down, select the ContactName column.
Under the Appearance section, from the drop-down of the UniqueValueCasing property, select Camel .
4. Click the OK button.
The following code demonstrates how to set the UniqueValueCasing property to Camel on grid level in the ASPX markup.
In ASPX:
<Behaviors>
<ig:Filtering FilterType="ExcelStyleFilter" UniqueValueCasing="Camel">
</ig:Filtering>
</Behaviors>
The following code demonstrates how to set the UniqueValueCasing property to Camel on grid level in the ASPX markup. The setting is applied to a column with the key “ ContactName ” .
In ASPX:
<Behaviors>
<ig:Filtering FilterType="ExcelStyleFilter">
<ColumnSettings>
<ig:ColumnFilteringSetting ColumnKey="ContactName" UniqueValueCasing="Camel" />
</ColumnSettings>
</ig:Filtering>
</Behaviors>
The following code demonstrates how to set the UniqueValueCasing property to Camel on grid level in the code-behind.
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;
//Set the UniqueValueCasing to Camel on Grid level
this.WebDataGrid2.Behaviors.Filtering.UniqueValueCasing = UniqueValueCasing.Camel;
The following code demonstrates how to set the UniqueValueCasing property to Camel on grid level in the code-behind. The setting is applied to a column with the key “ ContactName ” .
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 the UniqueValueCasing to Camel on column level
settingColumn.UniqueValueCasing = UniqueValueCasing.Camel;
//Add the created ColumnSetting
this.WebDataGrid2.Behaviors.Filtering.ColumnSettings.Add(settingColumn);
Setting the null value text allows you to change the text for the item in the filter drop-down. This text will be displayed for the items that have a Null value in the data source / database. The NullValueText property is of type string and has a default value of Null .
The following table maps the desired configuration of the NullValueText property settings:
To complete the procedure, you need the following:
An ASP.NET Web project with a WebDataGrid instantiated on 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.)
To set the NullValueText to My Null on WebDataGrid using the Designer:
1. From the smart tag of the WebDataGrid, open the WebDataGrid Designer.
2. From the left pane, select the desired filtering behavior.
3. From the right pane, set the NullValueText property to My Null .
4. Click the OK button.
The following code demonstrates how to set the NullValueText of the WebDataGrid to “My Null” in the markup.
In ASPX:
<Behaviors>
<ig:Filtering FilterType="ExcelStyleFilter" NullValueText="My Null">
</ig:Filtering>
</Behaviors>
The following code demonstrates how to set the NullValueText of the WebDataGrid to “My Null” in the code behind:
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;
//Set the NullValueText property to "My Null"
this.WebDataGrid2.Behaviors.Filtering.NullValueText = "My Null";
The following topics provide additional information related to this topic:
The following samples provide additional information related to this topic.