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

Glossary Item Box

This topic contains the following sections:

Introduction

WebGrid allows a hierarchical data source to be displayed in hierarchical navigation layout. It supports unlimited nested tables inside another table and provides sophisticated data analytical presentation. It also includes built-in automatic functionality that handles the process of retrieving child row based on defined relationships, as well as flexibility to load child data on demand The latest WebGrid now supports hierarchical data binding through ISDataSource component, enabling you to bind hierarchical data instantly. Click here to learn more on ISDataSource support.

There are two types of hierarchical select operation supported in WebGrid:

Load all child tables DataSource (default)

By default, all tables defined in the dataset that are connected to the DataSource control will be loaded at first page request. For instance, a dataset containing hierarchical tables such as Customers => Orders => Order Details will have all three tables loaded. This default scenario is best used to display relatively small amount of hierarchical data.

With declarative hierarchical DataSource control support, displaying hierarchical data has never been easier. The following codes illustrate how the WebGrid can be declaratively connected to the DataSource control which is also declaratively defined.
Code Copy Code
<ISWebGrid:WebGrid ID="WebGrid1" runat="server" Height="300px" UseDefaultStyle="True"
Width="100%" DataMember="Customers" DataSourceID="ISDataSource1">
   <RootTable Caption="Customers" DataKeyField="CustomerID" DataMember="Customers">
      <ChildTables>
         <ISWebGrid:WebGridTable Caption="Orders" DataKeyField="OrderID" DataMember="Orders">
            <ChildTables>
               <ISWebGrid:WebGridTable Caption="Order Details" DataMember="Order Details">
                  <Columns>
                     ... columns definition
                  </Columns>
               </ISWebGrid:WebGridTable>
            </ChildTables>
               <Columns>
                  ... columns definition
               </Columns>
         </ISWebGrid:WebGridTable>
      </ChildTables>
      <Columns>
         ...columns definitions
      </Columns>
   </RootTable>
   <LayoutSettings Hierarchical="True">
   </LayoutSettings>
</ISWebGrid:WebGrid>
<ISDataSource:ISDataSource ID="ISDataSource1" runat="server" SchemaName="dsNorthwind">
   <Tables>
      <ISDataSource:ISDataSourceTable ConflictDetection="CompareAllValues" SelectMethod="GetData"
      TableName="Customers" TypeName="dsNorthwindTableAdapters.CustomersTableAdapter">
      </ISDataSource:ISDataSourceTable>
      <ISDataSource:ISDataSourceTable ConflictDetection="CompareAllValues" SelectMethod="GetData"
      TableName="Orders" TypeName="dsNorthwindTableAdapters.OrdersTableAdapter">
      </ISDataSource:ISDataSourceTable>
      <ISDataSource:ISDataSourceTable ConflictDetection="CompareAllValues" SelectMethod="GetData"
      TableName="Order Details" TypeName="dsNorthwindTableAdapters.Order_DetailsTableAdapter">
      </ISDataSource:ISDataSourceTable>
   </Tables>
</ISDataSource:ISDataSource>


The ISDataSource control provides easy-to-use designer for connecting the DataSource to the dataset that available in the web application. The designer has the capability to retrieve the table schemas, type name, data object methods, as well as automatic conflict detection.

Although ISDataSource control can be declaratively written in html view mode, it is best practice to configure the DataSource at design time using the provided designer. The above sample has the markup generated by ISDataSource Designer.
To learn more about ISDataSource licensing when used together with WebGrid, see About ISDataSource licensing in WebGrid.NET Enterprise 5.0.

 

Load child tables DataSource on demand

Data binding and on demand data retrieval concept has significantly changed in WebGrid along with the new DataSource control support.

In previous versions, WebGrid is serving as both User Interface and Data Access component. By being Data Access component, it means WebGrid also handles the DataSource level functions such as initializing the DataSource and performing on demand function on Grid level through events.

In version 5 with DataSource control support, WebGrid is now serving as pure User Interface control. That means WebGrid no longer handle DataSource level manipulation. Instead, WebGrid simply connects to a DataSource control which primarily performing data retrieval and data manipulation. With this new concept, WebGrid simply displays a valid DataSource that has been successfully retrieved by DataSource control.
The new concept affects WebGrid's mechanism for loading child tables on demand. Several important points for loading child tables on demand in version 5.0:

Configuring a WebGrid to display load on demand child table is now easier and simpler. There is no configuration needed to set at WebGrid level.

At ISDataSource DataSource control level, you can enable load on demand operation by simply setting LoadOnDemand property to True. Next, you provide the method that retrieve the child table data and assign it to the ISDataSource control.

Code Copy Code
< ISDataSource : ISDataSource ID="ISDataSource1" runat="server" LoadOnDemand="True"
                SchemaName="dsNorthwind">
...
</ISDataSource:ISDataSource>

There are two ways to provide the method for retrieving child table data:

Once the ISDataSource control has been successfully configured, WebGrid will be able to automatically perform load on demand data retrieval without additional settings or codes at WebGrid level.

 

Hierarchical strongly typed collection

Easily bind hierarchical business objects in the same way and manner as in DataSet objects. WebGrid is the first grid component that implements extensive support to bind your custom hierarchical objects in an elegant, strongly-typed object approach.

 

Walkthrough Topics

Walkthrough: Binding WebGrid to Hierarchical ISDataSource control

Walkthrough: Configuring updatable WebGrid bound to ISDataSource control

Walkthrough: Loading child rows on demand based on the selected parent row

See Also

©2012 Intersoft Solutions Corp. All Rights Reserved.