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

Radgrid with multi detail tables

2 Answers 127 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ToltingColtAcres
Top achievements
Rank 2
Veteran
Iron
ToltingColtAcres asked on 12 Sep 2016, 06:58 PM

I have a radgrid with a 3-tier structure (master -> detail -> detaildetail)

In my ItemDataBound event:

protected void RadGrid_ItemDataBound(object sender, GridItemEventArgs e)
{
 ... code referencing e.Item
}

how can I determine which "tier" e.Item is?

The <telerik:GridTableView> markup does not appear to allow me to specify a separate ItemDataBound handler for each "tier".

Thanks,


.

.

.

2 Answers, 1 is accepted

Sort by
0
Pierre
Top achievements
Rank 1
answered on 13 Sep 2016, 06:46 AM
Hi,

There is 2 way to travel through the nested hierachy.
Depending on your HierarchyLoadMode.

If i need to access detail tables , items etc .
I add a OnPreRender in the MasterTableView.

protected void Unnamed_PreRender(object sender, EventArgs e)
{
    MyControler(RadGRID_MASTER.MasterTableView);
}

.


  private void MyControler(GridTableView gridTableView)
{
    GridItem[] nestedViewItems = gridTableView.GetItems(GridItemType.NestedView);
 
    foreach (GridNestedViewItem nestedViewItem in nestedViewItems)
    {
 
        foreach (GridTableView nestedView in nestedViewItem.NestedTableViews)
        {
            // Here you can operate your controls the way you want.
             
                // nestedView.Name == "LAC" Name of the current DetailTable
                // gridTableView.Name == "Dad"  Name of the parent Table.
            if (nestedView.Name == "LAC" && nestedView.Items.Count == 0)
                // Do stuff
                 
                }
 
            if(nestedView.HasDetailTables)
                { MyControler(nestedView); }
        }
    }
}

I hope this will help you.
Regards,
Pierre

.
0
ToltingColtAcres
Top achievements
Rank 2
Veteran
Iron
answered on 13 Sep 2016, 05:54 PM

I managed to find a solution:

 

protected void RadGrid_ItemDataBound(object sender, GridItemEventArgs e)
{
   String sName = e.Item.OwnerTableView.Name;
...
   if ( e.Item is GridEditFormItem && sName == "Header" )
   {
      ...
   }
...
}

Tags
Grid
Asked by
ToltingColtAcres
Top achievements
Rank 2
Veteran
Iron
Answers by
Pierre
Top achievements
Rank 1
ToltingColtAcres
Top achievements
Rank 2
Veteran
Iron
Share this question
or