I am exploring telerik datagrid for one of my requirement in project. I have tried the demo samples but none of them suits my requirement so please suggest me how I can achieve following requirement,
I need to show the hierarchy in grid dynamically. Initially I only know my base node (i.e. MasterTableView ) data. After loading the
data user will expand rows in MasterTableView & at the run time I will create DetailTables & bind grid with it. (so basically I want to create a child grid at runtime, the level of hierarchy is not defined it can grow to any level)
so the structure will be
Thansk in advance
6 Answers, 1 is accepted
This scenario can be implemented with a series of nested RadGrids. You will have to recursively create RadGrid instances in the NestedViewTemplate of the previous parent grid. To do that you need to:
1. Use RadGrid's ItemCreated event to add nested grids to each GridNestedViewItem that is created. This is the item that holds the nested template:
2. Use RadGrids' ItemCommand event to bind the inner grid:
3. Define the inner RadGrid instances recursively by attaching the same ItemCommand, ItemCreated and NeedDataSource event handlers to all of them:
What happens is that each inner grid that is rebound creates other inner grids in its nested items. The recursion is constrained by RadGrid's data - if a RadGrid's data source contains 0 items (indicating end of current hierarchical branch), no data items are created for the current RadGrid instance. This means no child grids will be instantiated further down.
Attaching a test page to demonstrate this approach.
All the best,
the Telerik team
Node lines like RadTreeView's are not supported by RadGrid. If you need true TreeView experience, you can use RadTreeView and its NodeTemplate functionality to build content dynamically inside RadTreeView nodes.
the Telerik team