In order to display hierarchical data, Telerik RadGrid renders one or more detail tables
for each item in the
MasterTableView (i.e. for each data-row that MasterTableView
renders). In three level hierarchy for each item of each detail table there are one or more
detail items as well. The level of hierarchy may be virtually infinite.
To bind each detail table-view, Telerik RadGrid fires the
DetailTableDataBind event.
The argument carries all needed information such as the table that should be data bound,
parent item(s), etc. In the code of the
DetailTableDataBind event handler
you should write code for constructing detail data-source (list of objects) that will be
used by the table to be bound to the hierarchical structure. The DataSource should be
filtered in the appropriate manner, i.e. it should contain only child-records of the
parent item is bound to.
Below are the main steps when binding your grid instance to hierarchical data source through
the
DetailTableDataBind event of the control:
- create the grid statically/dynamically on the page
- specify preferred settings for your grid instance through its properties.
- attach the DetailTableDataBind event to the control after you instantiate
the grid
- assign datasources for the grid tables in the DetailTableDataBind handler
of the grid. In DetailTableDataBind you can determine which datasource should be related
to the currently bound GridTableView by checking its DataMember property
or DataSourceID property (when using data source controls under ASP.NET 2.0).
Here the DataMember/DataSourceID property must have unique value for each detail
table (this value has to be defined previously by the developer). The DataSourceID
is the ID of the DataSource control responsible for the corresponding detail table
content generation.
This online demo demonstrates the hierarchy model of Telerik RadGrid. A
three level hierarchy is demonstrated with
Customer Master Table and
two nested Detail Tables
Orders and
OrderDetails using
DetailTablesDataBind event.
Note that hierarchical grid structure is not supported with simple data-binding
(calling DataBind()). See the
Simple data binding demo from the
Populating with
data section for more info about the limitations of this binding mode.
For additional info please follow this link:
DetailTableDataBind hierarchy generation