Intersoft WebGrid Documentation
Self-referencing Binding
See Also Send comments on this topic.
Intersoft WebGrid > WebGrid Features Overview > Displaying Data > Server-side Binding > Self-referencing Binding

Glossary Item Box

WebGrid's self-reference feature is unique in the way that it is implemented as a new feature without trading-off the other existing features. Therefore you can still enable normal Hierarchical mode along with the SelfReferencing feature, enabling sophisticated and never-possible-before scenarios to be implemented easily. As part of WebGrid's vision, the feature also supports LoadOnDemand capability which built on the top of the OnTheFly architecture. This allows developers to implement their own logic to fetch large data tables.

This topic contains the following sections:

Introduction

The self referencing table concept in WebGrid actually shares the same table structure and is not a "real" hierarchical drill-down mode. We only see the self referencing mode as another way to group and order the data in a way that follows specific constraints (that is ParentDataMember and ChildMember) to produce a convenient, well-ordered and expandable structure of rows. Therefore, WebGrid's powerful Hierarchical mode is not conflicted and can be enabled along with self referencing mode.

The child and parent recursive implementation is fully based on ADO.NET mechanism. That means if you apply the same child and parent member setting to ADO.NET, you will get the same results.

Settings available in SelfReferencingSettings:

Properties Description
ChildDataMember The child member of self referencing table.
Enabled Specifies whether self referencing is enabled for this table.
ExpandColumnInnerTextPadding Specifies the padding for expand column's inner text area.
ExpandColumnMember Specifies where the expand/collapse icon will be rendered.
FitColumnOnExpand Automatically best fit expand column when expanded.
IsTreeViewSelectionMode Whether the self referencing will use tree view selection mode.
LoadOnDemand Specifies whether child rows will be populated on demand.
ParentDataMember The parent member of self referencing table.
ParentRootMode Determines how parent rows are populated.
TreatOrphanRecordsAsRoot Determines whether rows that doesn't have parent or child will be treated as root.

In order to enable basic self referencing table, simply set Enabled to True, and specify both ChildDataMember and ParentDataMember from dropdown in designer.

WebGrid now introduces a new setting in SelfReferenceSettings object called ApplyChildSorting. This feature instructs WebGrid to perform sorting on the self referencing child when the column sorting action occurred.

Load on Demand Implementation

Load on demand feature enables you to retrieve the child rows when the specific parent node is clicked. This flexible feature allows larger data table to be retrieved efficiently. When working in load on demand mode, the first time the page loads, it will only populate the parent rows and hence you only need to supply the parent rows DataSource. Next, you need to implement InitializeSelfReferenceDataSource server event to handle the process of retrieving childrows' datasource. In the event, you only need to fill the childrows into the datatable like in the sample below, the grid will be able to automatically populate the childrows without additional codes.

Note:Since Hierarchical and SelfReferencing can be both enabled at the same time, load on demand for both features can also be enabled in such advanced scenarios. Simply handle InitializeChildTableDataSource for Hierarchical mode and InitializeSelfReferenceDataSource for SelfReferencing mode. See the following screenshot for the results.

Sorting Child Rows

WebGrid now introduces a new setting in SelfReferenceSettings object called ApplyChildSorting. This feature instructs WebGrid to perform sorting on the self-referencing child when the column sorting action occurred. 

For more information:

See Also

©2012 Intersoft Solutions Corp. All Rights Reserved.