Version

Enabling Excel Style Filtering

Topic Overview

Purpose

This topic demonstrates how to enable the Excel-Style Filtering feature 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.

Introduction

Enabling Excel-Style Filtering summary

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:

Enabling Excel-Style Filtering property settings

The following table maps the desired filtering behavior to the property settings that configure it:

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

Enable Excel-Style Filtering

ExcelStyleFilter

Disable filtering on a column

false

Enabling Excel-Style Filtering Using the Designer

Introduction

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.

Preview

The following screenshot is a preview of the final result:

WHDG ExcelStyleFiltering Enabling 1.png

Prerequisites

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.)

Overview

Following is a conceptual overview of the process: 1. Enabling Excel-Style Filtering

2. (Optional) * Verifying the result*

Steps

The following steps demonstrate how to Enable Excel-Style Filtering using the Designer.

1. Enable Excel-Style Filtering.

1. Launch the Edit Grid Behaviors dialog.

Click on the smart tag of the WebHierarchicalDataGrid and then select the Edit Behaviors option .

WHDG ExcelStyleFiltering Enabling 2.png

The WebDataGrid Designer dialog opens up. 2. Enable Excel-Style Filtering on both the parent and child levels.

  1. In the Edit Grid Behaviors dialog. dialog, in the left-hand side panel, check Filtering .

  2. In the right-hand side panel, set the * FilterType* property to ExcelStyleFilter .

  3. In the right-hand side panel, set the EnableInheritance property to True .

These settings enable filtering and allow it for the child bands.

WHDG ExcelStyleFiltering Enabling 3.png
  1. Click the OK button .

3. (Optional) Verify the result.

To verify the result, save and run the project, then test the filtering behavior of the WebHierarchicalDataGrid .

Enabling Excel-Style Filtering in the ASPX Markup

Overview

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.

Preview

The following picture demonstrates the result generated by the code in this example.

WHDG ExcelStyleFiltering Enabling 4.png

Code

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>

Enabling Excel-Style Filtering in the Code-Behind

Overview

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.

Preview

The following picture demonstrates the result generated by the code in this example.

WHDG ExcelStyleFiltering Enabling 4.png

Code

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);
        }

Related Content

Topics

The following topics provide additional information related to this topic:

Topic Purpose

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

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.