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

Changing a nested grid columns

2 Answers 62 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Eric Klein
Top achievements
Rank 1
Eric Klein asked on 03 Dec 2009, 01:59 PM
I have a grid that has a nested view.  When the parent is expanded depending on the user type I want to hide a column.  I know how to do this for the master table.

RadGrid1.MasterTableView.RenderColumns[10].Display = false

but RadGrid2 is a NestedViewTemplate.  When ever I attempt to reference RadGrid2 it tells me it does not exist in current context.  I am assuming I still need to do this in the RadGrid2_PreRender event.

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 03 Dec 2009, 02:22 PM
Hi Eric,

You can try out the following code to achieve the required:
c#:
RadGrid1.MasterTableView.Columns[0].Visible = false
foreach (GridNestedViewItem nestedItem in RadGrid1.MasterTableView.GetItems(GridItemType.NestedView)) 
  { 
      RadGrid grid = (RadGrid)nestedItem.FindControl("Radgrid2"); 
      grid.MasterTableView.Columns[0].Visible = false
  }  

Thanks
Princy.
0
Eric Klein
Top achievements
Rank 1
answered on 03 Dec 2009, 02:31 PM
Thanks Princy, that worked perfect.  Didn'y know  I had to loop through the GridNestedViewItem


Thanks again,
Eric
Tags
Grid
Asked by
Eric Klein
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Eric Klein
Top achievements
Rank 1
Share this question
or