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

Hierarchy back color: same as parent item's color

2 Answers 98 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sameers
Top achievements
Rank 1
Sameers asked on 22 Aug 2011, 11:50 AM
Is it possible to have the detail table rows color (both alternative and normal) the same as the color of the parent row?

So, if the back color of parent item is white, all rows of the child table should go white. Similarly, if the back color of the parent row is light gray, all child rows in detail table should have light gray!

Is that something possible?
thanks,
Sameers

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 22 Aug 2011, 02:00 PM
Hello Sameers,
Try the following code snippet to achieve your scenario.
C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
        if ((e.Item is GridDataItem) && (e.Item.OwnerTableView.Name == "Detail")&&(e.Item.OwnerTableView.ParentItem.ItemType==GridItemType.Item))
        {
            GridDataItem item = (GridDataItem)e.Item;
            item.BackColor = RadGrid1.MasterTableView.ItemStyle.BackColor;
        }
        else if ((e.Item is GridDataItem) && (e.Item.OwnerTableView.Name == "Detail") && (e.Item.OwnerTableView.ParentItem.ItemType == GridItemType.AlternatingItem))
        {
            GridDataItem item = (GridDataItem)e.Item;
            item.BackColor = RadGrid1.MasterTableView.AlternatingItemStyle.BackColor;
        }
    }

Thanks,
Shinu.
0
Sameers
Top achievements
Rank 1
answered on 22 Aug 2011, 02:38 PM

Thank you very much. It works well as expected.

Just a side note, I noticed that it works only if you explicitly define colors for the Item and AlternateItem in the Master Table view. If you dont define that, it wont work well. I had to define them manually like

 

<

 

ItemStyle BackColor ="White" />

 

 

 

 

 

 

<AlternatingItemStyle BackColor="#F2F2F2" />

 

 

 


And it worked. If I dont define them, it doesn't work.

Gerat Help.
Thanks
Sameers

Tags
Grid
Asked by
Sameers
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Sameers
Top achievements
Rank 1
Share this question
or