Programmatically selecting Hierarchical Data

2 posts, 0 answers
  1. Sebastian
    Sebastian avatar
    2 posts
    Member since:
    May 2012

    Posted 06 Feb 2015 Link to this post

    Hi all,

    Im using a RadGridView to display Data at 3 levels like so:

                    <telerik:RadGridView>
                        <telerik:RadGridView.ChildTableDefinitions>
                            <telerik:GridViewTableDefinition />
                        </telerik:RadGridView.ChildTableDefinitions>
                        <telerik:RadGridView.HierarchyChildTemplate>
                            <DataTemplate>
                                <telerik:RadGridView>
                                    <telerik:RadGridView.ChildTableDefinitions>
                                        <telerik:GridViewTableDefinition />
                                    </telerik:RadGridView.ChildTableDefinitions>
                                      <telerik:RadGridView.HierarchyChildTemplate>
                                        <DataTemplate>
                                            <telerik:RadGridView>


    What I need to do now, in code, is the following. I know a value for all of the 3 depth levels, which means expand at level 1, expand at level 2, select and scroll intoView on level 3. Unfortunately I don't know how to get the child grids in code, so that all I've achieved so far is scroll and expand at level 1.

    TIA
  2. Boris
    Admin
    Boris avatar
    276 posts

    Posted 11 Feb 2015 Link to this post

    Hi TIA,

    A possible way to reach the third level of the hierarchy is to subscribe to the DataLoading event of RadGridView. For example lets say you have a main grid named "clubsGrid", which has a child gridview named "playersGrid", which has a child gridview named "detailsGrid". Then you can do the following:

    public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
     
                this.clubsGrid.DataLoading += clubsGrid_DataLoading;
            }
     
            void clubsGrid_DataLoading(object sender, Telerik.Windows.Controls.GridView.GridViewDataLoadingEventArgs e)
            {
                GridViewDataControl dataControl = (GridViewDataControl)sender;
     
                if (dataControl.Name.Equals("playersGrid"))
                {
                    // Do something with the playersGrid
                }
                else if (dataControl.Name.Equals("detailsGrid"))
                {
                    // Do something with the detailsGrid               
                }
                else
                {
                    // Do something else
                }          
            }
        }

    For more information about this you can check the How-To: Set properties to the child gridview documentation article. As for the scrolling you can refer to the Scroll to a particular row or column article.

    I hope this helps.

    Regards,
    Boris
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top