Version

Configuring Excel Style Filtering

Configuring Excel-Style Filtering ( WebHierarchicalDataGrid )

Topic Overview

Purpose

This topic explains how to configure the Excel-Style Filtering options of the WebHierarchicalDataGrid™ control.

Required background

The following topics are prerequisites to understanding this topic:

Topic Purpose

This topic demonstrates how to bind the WebHierarchicalDataGrid to the WebHierarchicalDataSource™ component using the Categories and Products tables of the Northwind sample database.

This topic introduces the Excel-Style Filtering feature of the WebHierarchicalDataGrid control.

This topic provides reference about the properties that are specific to the Excel-Style Filtering feature of the WebHierarchicalDataGrid control.

Excel-Style Filtering Configuration Summary

Excel-Style Filtering configuration summary chart

The following table lists the configurable aspects of the Excel Style Filtering feature of the WebHierarchicalDataGird™ control.

Configurable aspects Details Properties

You can specify the capitalization of values into the filtering dropdown. The available options are: lowercase capitalization, uppercase capitalization, and camelcase capitalization.

You can specify custom text for Null values in the filtering drop-down.

Configuring the Capitalization of the Unique Values in the Filtering Drop-Down

Overview

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 several levels:

  • per column

  • per band (parent/child)

  • for the whole grid

The column setting takes the highest priority.

Property settings

The following table maps the desired capitalization configurations of the property settings that configure them:In order to: Use this property: And set it to:

Configure lowercase capitalization for the items in the filtering drop-down in lower case

Lower

Configure uppercase capitalization for the items in the filtering drop-down in upper case

Upper

Configure camelcase capitalization for the items in the filtering drop-down with only the first capitalized

Camel

Prerequisites

To complete the procedure, you need the following:

  • An ASP.NET Web project with a WebHierarchicalDataGrid instantiated on a web page

  • The WebHierarchicalDataGrid 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 WebHierarchicalDataGrid* topic.)

Configuring the capitalization of unique values using the Designer

Configuring the capitalization on grid level

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 .

WHDG ExcelStyleFiltering Configuring 1.png

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 .

Configuring the capitalization on*band level

The following example demonstrates how to configure the capitalization of the unique valies in the filtering drop-down for the first child band. In this example, the items are being set to appear in all-uppercase letters (The UniqueValueCasing property is being set to Upper .).

1*.* Add the child band * .*

WHDG ExcelStyleFiltering Configuring 2.png

2*.* * Configure filtering behavior for that band.*

WHDG ExcelStyleFiltering Configuring 3.png

Configuring the capitalization of unique values in the ASPX markup

The following code demonstrates how to configure, in the ASPX markup, the unique values with sentence capitalization for the parent (by setting the UniqueValueCasing property to Camel on the parent level) and with all-uppercase capitalization for the child (by setting the UniqueValueCasing property to Upper on the child level).

In ASPX:

<Behaviors>
    <ig:Filtering FilterType="ExcelStyleFilter"
    UniqueValueCasing="Camel">
    </ig:Filtering>
</Behaviors>
<Bands>
    <ig:Band Key="Products" DataMember="SQLDataSource_Products"
        DataKeyFields="CategoryID">
        <Behaviors>
            <ig:Filtering FilterType="ExcelStyleFilter"
            UniqueValueCasing="Upper">
            </ig:Filtering>
        </Behaviors>
    </ig:Band>
</Bands>

Configuring the capitalization of unique values in the code-behind

The following code demonstrates how to configure, in the code-behind, the unique values with sentence capitalization for the parent (by setting the UniqueValueCasing property to Camel on the parent level) and with all-uppercase capitalization for the child (by setting the UniqueValueCasing property to Upper on the child level).

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;
            this.WebHierarchicalDataGrid1.Behaviors.Filtering.UniqueValueCasing = UniqueValueCasing.Camel;
            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;
            e.Band.Behaviors.Filtering.UniqueValueCasing = UniqueValueCasing.Upper;
        }

Configuring the Text for the Null Values in the Filtering Drop-Down

Overview

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 default value of Null . This property can be set on both the parent and child levels. In this example, the NullValueText property is set to CHILD NULL for the child band.

Preview

The following picture demonstrates the null value items displayed as CHILD NULL as a result of setting the NullValueText property to CHILD NULL string.

WHDG ExcelStyleFiltering Configuring 4.png

Property settings

The following table maps the desired configuration to the property settings that create it.

In order to: Use this property: And set it to:

Set the text for the items with null values to CHILD NUL in the filtering drop-down of the child band.

CHILD NULL

Prerequisites

To complete the procedure, you need the following:

  • An ASP.NET Web project with a WebHierarchicalDataGrid instantiated on a web page

  • The WebHierarchicalDataGrid 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 WebHierarchicalDataGrid* topic.)

Configuring the text for the null values using the Designer

The screenshots below demonstrates how to set the NullValueText to “ CHILD NULL ” on the child band in the WebHierarchicalDataGrid™ using the designer. First open the Edit Bands from the smart tag of the WebHierarchicalDataGrid™. First the child band has to be added, after that filtering behavior with NullValueText set to “ CHILD NULL ”.

To set the NullValueText to My Null for the child band in the WebHierarchicalDataGrid using the Designer:

1. From the smart tag of the WebDataGrid, open the Edit WebHierarchicalDataGrid Bands dialog.

WHDG ExcelStyleFiltering Configuring 2.png

2. From the left pane, click and mark Filtering.

2. From the right pane, set the FilterType property to ExcelStyleFilter .

3. From the right pane, set the NullValueText property to My Null .

WHDG ExcelStyleFiltering Configuring 6.png

4. Click the OK button .

Configuring the text for the null values in the ASPX markup

The code snippet below demonstrates how to set the NullValueText property for the child band to “ CHILD NULL ” in the ASPX markup.

In ASPX:

<Bands>
    <ig:Band DataKeyFields="CustomerID" DataMember="SQLDataSource_Products"
        Key="Products">
        <Behaviors>
            <ig:Filtering FilterType="ExcelStyleFilter"
 NullValueText="CHILD NULL">
            </ig:Filtering>
        </Behaviors>
    </ig:Band>
</Bands>

Configuring the text for the null values in the code-behind

The code snippet below demonstrates how to set the NullValueText property for the child band to “ CHILD NULL ” from the code-behind.

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;
            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;
            e.Band.Behaviors.Filtering.NullValueText = "CHILD NULL";
        }

Related Content

Topics

The following topics provide additional information related to this topic.

Topic Purpose

This topic provides reference information about the properties that are specific to the Excel-Style Filtering feature of the WebHierarchicalDataGrid control.

Samples

The following samples provide additional information related to this topic.

Sample Purpose

This sample demonstrates Excel-Style Filtering with Bound and Unbound fields as well as with Bound and Unbound checkboxes.

This sample demonstrates Excel-Style Filtering with editing.