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

issue to access the parent column

1 Answer 57 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Himanshu
Top achievements
Rank 1
Himanshu asked on 26 Mar 2014, 11:11 AM
how to access the parent table column value in child table when we using the hierarchy of telerik grid.


cs source-

 protected void cmpreportgrid_OnItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {

         if (e.Item is GridDataItem)
        {
            if (e.Item.OwnerTableView.Name == "CompanyListDetails")
            {
                if (e.Item is GridDataItem)
                {
                    GridDataItem item = e.Item as GridDataItem;
                    Viewing view = item.DataItem as Viewing;
                    if (!view.isgroupcontact)
                    {
                       
                        item["ExpandColumn"].Text = "";
                    }
                    
                }  
            }
       else if (e.Item.OwnerTableView.Name == "GroupContact")
            {
                e.Item.OwnerTableView.ParentItem.Expanded=false;//how to get the parent table column here to set the condition for expandcolumn.
            }
            
        }
    }

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 27 Mar 2014, 03:21 AM
Hi Himanshu,

I'm not sure about your requirement. Please take a look at the following code snippet to access the Parent-table from child.

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
  if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "Child")
   {
    GridDataItem item = (GridDataItem)e.Item;
    //Access the parent row
    GridDataItem parentItem = item.OwnerTableView.ParentItem as GridDataItem;
    //Access the parent table
    GridTableView parentTable = item.OwnerTableView.ParentItem.OwnerTableView;         
   }
}

Please elaborate on your requirement if this doesn't help.
Thanks,
Princy
Tags
Grid
Asked by
Himanshu
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or