This is a migrated thread and some comments may be shown as answers.

Accessing Hierarchy Child Table from Code Behind

1 Answer 73 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tom
Top achievements
Rank 1
Tom asked on 13 Jul 2012, 03:30 PM
In my view I have a Hierarchy Grid structure that only goes down 1 level. I have a button on the screen that when pushed takes the selected item from that grid and adds it as a new object to another grid and removes the entry. The issue I have is from the code I cannot access the inner grid, its not even visible.

In addition I want to make it when an item is selected from the child grid it will de-select from the parent, acting as one large grid.

Is any of this possible?

1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 16 Jul 2012, 08:21 AM
Hi,


You can get the child grid for a particular row using ChildrenOfType<T> extension method. For example:

var row = this.clubsGrid.ItemContainerGenerator.ContainerFromItem(this.parentItem);
if(row != null)
      var childGrid = row.ChildrenOfType<GridViewDataControl>().FirstOrDefault();
}

Please keep in mind that you can access the ChildGrid after it has been initially loaded which happens the first time the hierarchy is expanded and the ChildGrid  is requested.

I would like to remind that RadGridView is a virtualized control and as such it recycles and reuses its visual elements on scrolling. That is why it is not recommended to work directly with the visual elements, but rather with the underlying data.  

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Tom
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or