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

Hierachial grid SelectedIndexChanged event

2 Answers 45 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Julia Helton
Top achievements
Rank 1
Julia Helton asked on 23 May 2012, 05:54 PM
How can I determine which level of the hierachy a selected row is a part of in the SelectedIndexChanged event?  Like for instance in the ItemCommand Event, I can check the e.CommandName to determine which level was clicked.

Example

Main level - row 1
    Detail level 1 - row 1
            Detail level 2 - row 1
            Detail level 2 - row 2

I want to know when Detail level 2 - row 1 is selected vs when the Main level being selected.

Thanks!


2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 24 May 2012, 06:19 AM
Hi Julia Helton,

Set the Name property of MasterTableView and GridTableViews. Please take a look into the following code snippet.

ASPX:
<MasterTableView Name="Master">
<DetailTables>
. . .
<telerik:GridTableView Name="Detail1">
<ParentTableRelation>
. . .
<DetailTables>
<telerik:GridTableView Name="Detail2">
<ParentTableRelation>
. . .

C#:
protected void RadGrid1_SelectedIndexChanged(object sender, EventArgs e)
{
    foreach (GridDataItem item in RadGrid1.SelectedItems)
    {
        if(item.OwnerTableView.Name=="Master")
        {
            // Row in MasterTableView is Clicked
        }
        if (item.OwnerTableView.Name == "Detail1")
        {
            // Row in 1st Detail Table is Clicked
        }
        if (item.OwnerTableView.Name == "Detail2")
        {
            // Row in 2nd Detail Table is Clicked
        }
    }  
}

Thanks,
Shinu.
0
Julia Helton
Top achievements
Rank 1
answered on 25 May 2012, 07:11 PM
Thanks!!!  This is exactly what I needed.
Tags
Grid
Asked by
Julia Helton
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Julia Helton
Top achievements
Rank 1
Share this question
or