Version

Enabling Excel Style Filtering

Topic Overview

Purpose

This topic demonstrates how to enable the Excel-Style Filtering feature of the WebDataGrid™ control.

Required background

The following topics are prerequisites to understanding this topic:

Topic Purpose

This topic demonstrates how to add WebDataGrid to a page and retrieve the Customers table of the Northwind sample database.

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

Introduction

Enabling Excel-Style Filtering summary

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:

Note
Note:

Excel-Style Filtering requires the WebDataGrid to bind its entire data source on each filter operation in order to create the filtered data set. Take this into consideration when tuning your application performance.

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 Excel-Style Filtering on all columns except one (ContactName) and disable filtering for that one column using the Designer.

Preview

The following screenshot is a preview of the final result:

WDG ExcelStyleFiltering Enabling 1.png

Prerequisites

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

Overview

Following is a conceptual overview of the process:

1. Enabling Excel-Style Filtering

2. Disabling Filtering on one column

3. (Optional) Verifying the result

Steps

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. Enable Excel-Style Filtering.

1. Launch the Behaviors Editor Dialog.

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

WDG ExcelStyleFiltering Enabling 2.png

The WebDataGrid Designer dialog opens up.

2. Enable Filtering.*

  1. In the WebDataGrid Designer dialog, in the left-hand side panel, check Filtering.

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

WDG ExcelStyleFiltering Enabling 3.png
  1. Click the Apply button .

2. Disable Filtering on one column.

1. Add a new column.

  1. Launch the Column Setting dialog.

With the Filtering box in the left pane checked, locate the ColumnSettings property and click the ellipsis (…) button .

WDG ExcelStyleFiltering Enabling 4.png

The Column Setting dialog opens up.

  1. Add a new column setting.

    1. In the left-hand side pane, click the add item option . The new column setting appears in the column settings collection.

    2. In the right-hand side pane, from the ColumnKey drop-down, select Add/Modify Columns.

WDG ExcelStyleFiltering Enabling 5.png

The Edit Grid Columns dialog opens up.

  1. Define the ContactName column.

    1. In the Edit Grid Columns dialog, from the Available Fields panel, select BoundField.

    2. Click on the Add Field button. The newly added field appears in the Selected Fields panel. (By default, its name is BoundColumn_0 .)

    3. From the Selected Fields panel, select the column which was just added.

    4. In the right-hand side pane, set the DataFieldName property to ContactName .

    5. In the right-hand side pane, set the Key property to ContactName .

WDG ExcelStyleFiltering Enabling 6.png
  1. Click OK to commit.

    1. Assign the newly created column to the ColumnKey property.

From the ColumnKey drop-down, select the ContactName column .

WDG ExcelStyleFiltering Enabling 7.png

2. Disable*filtering for the new column.

Set the Enabled property to False and then click OK to commit.

WDG ExcelStyleFiltering Enabling 8.png

3. (Optional) Verify the result.

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

Enabling Excel-Style Filtering in the ASPX Markup

Overview

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.

WDG ExcelStyleFiltering Enabling 1.png

Code

In ASPX:

<Behaviors>
    <ig:Filtering FilterType="ExcelStyleFilter">
        <ColumnSettings>
            <ig:ColumnFilteringSetting ColumnKey="ContactName" Enabled=" />
        </ColumnSettings>
    </ig:Filtering>
</Behaviors>

Enabling Excel-Style Filtering in the Code-Behind

Overview

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.

WDG ExcelStyleFiltering Enabling 1.png

Code

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

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 WebDataGrid control.

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

Samples

The following samples provide additional information related to this topic.

Sample Purpose

This sample demonstrates the Excel-Style Filtering’s UniqueValueCasing property.

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

This sample demonstrates h the NullValueText property of the Excel-Style Filtering, setting the string to Null .

This sample demonstrates Excel-Style Filtering with editing.