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

Hiding the Expand in the grid

2 Answers 53 Views
Grid
This is a migrated thread and some comments may be shown as answers.
John Giblin
Top achievements
Rank 1
John Giblin asked on 30 Nov 2012, 05:05 PM
I have a hierarchical grid that I have been implementing security on.

What I have done is limit the user to see only data they are allowed to see. So in the databind I skip over it if the user does not have access to that level of detail.  I would also like to remove the expand if they dont have access to the detailed info. Anyway to do that?

2 Answers, 1 is accepted

Sort by
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 01 Dec 2012, 03:55 AM
Hello,

RadGrid1.MasterTableView.ExpandCollapseColumn.Display = false;

//OR

  protected void RadGrid1_PreRender(object sender, EventArgs e)
    {
        HideExpandColumnRecursive(RadGrid1.MasterTableView);
    }
 
 
public static void HideExpandColumnRecursive(GridTableView tableView)
    {
        GridItem[] nestedViewItems = tableView.GetItems(GridItemType.NestedView);
        foreach (GridNestedViewItem nestedViewItem in nestedViewItems)
        {
            foreach (GridTableView nestedView in nestedViewItem.NestedTableViews)
            {
 
                System.Web.UI.WebControls.TableCell cell = nestedView.ParentItem["ExpandColumn"];
 
                if (cell.Controls.Count == 0)
                {
                }
                else
                {
                    cell.Controls[0].Visible = false;
                }
                nestedViewItem.Visible = false;
 
                if (nestedView.HasDetailTables)
                {
                    HideExpandColumnRecursive(nestedView);
                }
            }
        }
    }



Thanks,
Jayesh Goyani
0
John Giblin
Top achievements
Rank 1
answered on 03 Dec 2012, 04:25 PM
thanks Jayesh.  The first one did the trick
Tags
Grid
Asked by
John Giblin
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
John Giblin
Top achievements
Rank 1
Share this question
or