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

Programmatically selecting Hierarchical Data

1 Answer 155 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sebastian
Top achievements
Rank 1
Sebastian asked on 06 Feb 2015, 02:41 PM
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

1 Answer, 1 is accepted

Sort by
0
Boris
Telerik team
answered on 11 Feb 2015, 09:24 AM
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.

 
Tags
GridView
Asked by
Sebastian
Top achievements
Rank 1
Answers by
Boris
Telerik team
Share this question
or