Accessing Hierarchy Child Table from Code Behind

2 posts, 0 answers
  1. Tom
    Tom avatar
    12 posts
    Member since:
    Sep 2011

    Posted 13 Jul 2012 Link to this post

    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?
  2. Dimitrina
    Dimitrina avatar
    3769 posts

    Posted 16 Jul 2012 Link to this post


    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.  

    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top