If you work in hierarchy mode, you can define when the data binding for GridTableView
will occur. In order to do this, you need to set the following property:
GridTableView.HierarchyLoadMode
The possible values are:
- HierarchyLoadMode.ServerBind - all child GridTableViews will be bound immediately
when DataBind occurs for a parent GridTableView or RadGrid.
- HierarchyLoadMode.ServerOnDemand - data binding of a child GridTableView will
only take place when an item is expanded. This is the default value.
- HierarchyLoadMode.Client is similar to HierarchyLoadMode.ServerBind
but the items are expanded client-side, using JavaScript manipulations instead of postback
to the server.
In order to use client-side hierarchy expand, you will need to set also
ClientSettings.AllowExpand.Collapse to
true (which is the default value).
Changing the
GridTableView.HierarchyLoadMode property value impacts the performance
in the following way:
In
HierarchyLoadMode.ServerBind mode:
- The roundtrip to the database happens only once - when the grid is bound.
- The ViewState holds all data for the detail tables.
- Only detail table-views for the expanded items are rendered.
- You need to postback to the server to in order to expand an item.
In
HierarchyLoadMode.ServerOnDemand mode:
- The roundtrip to the database happens when the grid is bound and when an item is
expanded.
- The ViewState holds data only for the visible Items (the smallest possible ViewState).
- Only detail table-views of the expanded items are rendered.
- You need to postback to the server in order to expand an item.
In
HierarchyLoadMode.Client mode:
- The roundtrip to the database happens only when grid is bound.
- The ViewState holds all detail tables data.
- All items are rendered - even if not visible (not expanded).
- No postback to the server is needed to expand an item -
expand/collapse of hierarchy items is managed client-side.
Note: When setting
HierarchyLoadMode = Client you should also set
ClientSettings -> AllowExpandCollapse = true for your grid instance.
This example shows the advanced hierarchy model of Telerik RadGrid with client-side
expand/collapse.
A three level hierarchy is demonstrated with Customer Master Table and two nested Detail Tables
- Orders and OrderDetails. All grid levels have set
GridTableView.HierarchyLoadMode.Client.