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

Indicator if child row has data?

2 Answers 17 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 08 Jul 2013, 10:06 AM
When the grid control displays its data, the child rows are collapsed and the user needs to click on the arrow to the left to expand it and the only way a user knows if a row has child data is to expand it.  Is there a way to have the expand arrow (or some other way) display a different color if there are child rows?  I don't want to expand every child row as that would make it difficult for the users to quickly find the data they want.

2 Answers, 1 is accepted

Sort by
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 08 Jul 2013, 10:30 AM
Hello,

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)
            {
                if (nestedView.Items.Count == 0)
                {
                    System.Web.UI.WebControls.TableCell cell = nestedView.ParentItem["ExpandColumn"];
 
                    if (cell.Controls.Count == 0)
                    {
                    }
                    else
                    {
                        cell.Controls[0].Visible = false;
                        //cell.BackColor = System.Drawing.Color.Red;
                    }
                    nestedViewItem.Visible = false;
                }
                if (nestedView.HasDetailTables)
                {
                    HideExpandColumnRecursive(nestedView);
                }
            }
        }
    }


Thanks,
Jayesh Goyani
0
Jon
Top achievements
Rank 1
answered on 08 Jul 2013, 10:38 AM
Thanks much.  Do you have this code snippet in VB?
Tags
Grid
Asked by
Jon
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Jon
Top achievements
Rank 1
Share this question
or