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

Row Group expander

1 Answer 182 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Donnie
Top achievements
Rank 1
Donnie asked on 24 Mar 2009, 08:16 PM
When I load a dataset into the gridview I would like to set the backcolor of the expander box if there is child rows. Is it possible if so then how do I grab box to set the backcolor.

1 Answer, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 25 Mar 2009, 01:07 PM
Hi Donnie,

You should handle the ViewCellFormatting event and call the GetChildRows method to distinguish when there are no child rows for a specific row. Here is a sample:

void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e) 
    if (e.CellElement is GridGroupExpanderCellElement) 
    { 
        GridViewDataRowInfo row = (GridViewDataRowInfo)e.CellElement.RowInfo; 
        if (row.ViewTemplate.ChildGridViewTemplates.Count > 0) 
        { 
            GridViewRowInfo[] rows = row.ViewTemplate.ChildGridViewTemplates[0].GetChildRows(row); 
            if (rows != null && rows.Length > 0) 
            { 
                e.CellElement.DrawFill = true
                e.CellElement.GradientStyle = GradientStyles.Solid; 
                e.CellElement.BackColor = Color.SkyBlue; 
                return
            } 
        } 
        e.CellElement.DrawFill = false
    } 

I hope this helps. If you have further questions, please don't hesitate to ask.

Kind regards,
Jack
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
Donnie
Top achievements
Rank 1
Answers by
Jack
Telerik team
Share this question
or