Access to hierarchical grids

6 posts, 0 answers
  1. Andrew
    Andrew avatar
    10 posts
    Member since:
    Jul 2010

    Posted 16 Jul 2010 Link to this post

    Hello guys.
    I''ve got common hierarchical design grids;
    <telerikGridView:RadGridView  Grid.Row="1" HorizontalAlignment="Left" x:Name="grRegistrateProducts"/>
                <telerikGridView:RadGridView.ChildTableDefinitions>              
                    <telerikGridView:GridViewTableDefinition>
                        <telerikGridView:GridViewTableDefinition.Relation>
                            <telerikData:PropertyRelation ParentPropertyName="WorkPlaces" />
                        </telerikGridView:GridViewTableDefinition.Relation>
                    </telerikGridView:GridViewTableDefinition>                   
                </telerikGridView:RadGridView.ChildTableDefinitions>           
                <telerikGridView:RadGridView.HierarchyChildTemplate>
                    <DataTemplate>
                        <telerikGridView:RadGridView ItemsSource="{Binding WorkPlaces}" x:Name="grWorkPlaces" ShowGroupPanel="False" AutoGenerateColumns="False">
                            <telerikGridView:RadGridView.Columns>
                                <telerikGridView:GridViewDataColumn UniqueName="Id" IsReadOnly="True" MinWidth="200" MaxWidth="400"/>
                            </telerikGridView:RadGridView.Columns>
                        </telerikGridView:RadGridView>
                    </DataTemplate>
                </telerikGridView:RadGridView.HierarchyChildTemplate>
                <telerikGridView:RadGridView.Columns>
                    <telerikGridView:GridViewDataColumn UniqueName="Name" IsReadOnly="True" MinWidth="200" MaxWidth="400"/>
                </telerikGridView:RadGridView.Columns>
     </telerikGridView:RadGridView>
    I need acces to inrenalGrid.CurrentItem. But at code I can't access to my grWorkPlaces. So what's wrong? And what should I do?
    Thanks.
  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 16 Jul 2010 Link to this post

    Hi Andrew,

    You can access the child grid with the help of the extension method ChildrenOfType<>. For example:

    var selectedRow = (GridViewRow)this.clubsGrid.ItemContainerGenerator.ContainerFromItem(this.clubsGrid.SelectedItem);
    var childGrid = selectedRow.ChildrenOfType<GridViewDataControl>().FirstOrDefault();
    if (childGrid != null)
       {               
        Player currentPlayer = childGrid.CurrentItem as Player;
       }

    You can find more information about the extension methods ChildrenOfType<> and ParentOfType<> in this blog post.

    Regards,
    Maya
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. Muhammad
    Muhammad avatar
    24 posts
    Member since:
    Mar 2012

    Posted 20 Apr 2012 Link to this post

    Hi Maya(Admin),
    i got a query ,i have collection of objects which are not hierarchical but i want to display them in hierarchical grid.can you please tell me how i can set the hierarchical (inner nested grid) itemssource from the source code(dynamically)
    with regards
  5. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 20 Apr 2012 Link to this post

    Hello,

    You can use the Row Details feature for that purpose and set the ItemsSource of your child grid (that is inside the row details template) to anything that you want in the LoadingRowDetails event handler.

    Regards,
    Ross
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  6. Dave Navarro
    Dave Navarro avatar
    150 posts
    Member since:
    Jul 2005

    Posted 28 May 2012 Link to this post

    Hello,

    I also have a child grid and I need to add a double click event to it.

    With my parent grids I'd do it like this;
    this.radGVRecords.AddHandler(GridViewCellBase.CellDoubleClickEvent, new EventHandler<RadRoutedEventArgs>(OnCellDoubleClick), true);

    I usually place this code after my "InitializeComponent(); " line of code but I'm not sure now to achieve the same results with a child grid.

    Please let me know and thanks!

    ~ Dave
  7. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 29 May 2012 Link to this post

    Hi,

     To get reference to your child grid instance you can for example declare it using HierarchyChildTemplate and use Loaded event of the child grid itself. 

    Regards,
    Vlad
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top
DevCraft banner