Version

Configuring Multi-Column Headers

Topic Overview

Purpose

This topic shows how to setup multi-column headers in the WebHierarchicalDataGrid .

Required background

The following table lists the topics required as a prerequisite to understanding this topic.

Topic Purpose

This topic explains how to bind WebHierarchicalDataGrid to Northwind database.

Configuring Multi-Column Headers – Conceptual Overview

Multi-column headers configuration summary

If you need to create multiple levels of headers or group them into categories, enabling multi-column headers provides this functionality. The GroupField object is a field that accepts other columns in its columns collection. The header of the GroupField then displays above the columns in its columns collection. The resizing, sorting, selection, filtering, and moving grid behaviors are re-designed to meet the needs of this new layout.

Requirements

Web Hierarchical DataGrid bound to data.

Property settings

The following table lists the aspects in which multi-column headers can be configured and maps them to the respective properties that manage them.

Configurable aspect Properties

Multi-column headers

Configuring multi-column headers – Code Example

Introduction

In this example we will define GroupField object which will group contact information fields. Then we will add two BoundDataField objects to the field’s Columns collection. These fields will hold ContactName and ContactTitle column data.

Preview

The following screenshot is a preview of the final result.

Configuring Multi Column Headers(WHDG) 1.png

Requirements

To complete the procedure, you need a WebHierarchicalDataGrid bound to the suppliers table of the Northwind sample database.

Overview

This topic takes you step-by-step toward configuring multi-column headers for WebHierarchicalDataGrid . The following is a conceptual overview of the process:

Steps

The following steps demonstrate how to configure Multi-Column headers.

1. Defining a GroupField

A GroupField is defined like any other column. It is not bound to data but does require a key like other columns.

In ASPX:

<ig:GroupField Key="ContactInfo">
</ig:GroupField>

In C#:

GroupField groupField = new GroupField();
groupField.Key = "ContactInfo";
this.WebHierarchicalDataGridView.Columns.Add(groupField);

2. Configuring the header text

The header text is the text that is displayed for the column. Configure this on the Text property of the GridField’s Header object.

In ASPX:

<Header Text="Contact Information" />

In C#:

groupField.Header.Text = "Contact Information";

3. Adding columns to the GroupField’s columns collection

In order to show the child columns, add them to the Columns collection of the GroupField.

In ASPX:

<Columns>
    <ig:BoundDataField DataFieldName="ContactName" Key="ContactName">
        <Header Text="Contact" />
    </ig:BoundDataField>
    <ig:BoundDataField DataFieldName="ContactTitle" Key="ContactTitle">
        <Header Text="Title" />
    </ig:BoundDataField>
</Columns>

In C#:

/* Creating a  BoundDataField * /
BoundDataField field = new BoundDataField();
field.DataFieldName = "ContactName";
field.Key = "ContactName";
field.Header.Text = "Contact";
/* Adding the BoundDataField to be under the GroupedField
* which was created above
*/
groupField.Columns.Add(field);
/* Creating a  BoundDataField * /
field = new BoundDataField();
field.DataFieldName = "ContactTitle";
field.Key = "ContactTitle";
field.Header.Text = "Title";
/* Adding the BoundDataField to be under the GroupedField
* which was created above
*/
groupField.Columns.Add(field);

Related Content

Topics

The following topics provide additional information related to this topic.

Topic Purpose

This topic explains how to bind WebHierarchicalDataGrid to Northwind database.

This topic lists the behaviors you can configure with WebHierarchicalDataGrid .

Samples

The following samples provide additional information related to this topic.

Sample Purpose

This sample shows how to configure multi-column headers in WebHierarchicalDataGrid .