Changing a nested grid columns

3 posts, 1 answers
  1. Eric Klein
    Eric Klein avatar
    183 posts
    Member since:
    Aug 2009

    Posted 03 Dec 2009 Link to this post

    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. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 03 Dec 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Eric Klein
    Eric Klein avatar
    183 posts
    Member since:
    Aug 2009

    Posted 03 Dec 2009 Link to this post

    Thanks Princy, that worked perfect.  Didn'y know  I had to loop through the GridNestedViewItem


    Thanks again,
    Eric
Back to Top