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

hide the expand image

1 Answer 31 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joslyn
Top achievements
Rank 1
Joslyn asked on 21 Oct 2013, 11:58 AM
Hi,
how to hide the expand image for those rows that donot have any child rows in it. I dont want the user to simply expand a row if there are no rows in the child. How to do this.

Thanks,
Joslyn.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 21 Oct 2013, 12:01 PM
Hi Joslyn,

Please try the following code snippet to hide hide rows that don't have child.

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

Thanks,
Princy

Tags
Grid
Asked by
Joslyn
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or