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

Background Colour of NestedViewTemplate

2 Answers 140 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Neil N
Top achievements
Rank 1
Iron
Veteran
Iron
Neil N asked on 02 Sep 2008, 03:09 PM
The NestedViewTemplate of a grid always consists of one row showing the comment text pertaining to the parent row.  The parent rows have alternating background colours.  How can I get the background colour of the nested row to match the colour of its parent row?

2 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 02 Sep 2008, 03:35 PM
Hi Neil,

Please refer to the following code library example:

How to Obtain Reference to RadGrid DetailTables' Containing Rows and Cells, and Customize Their Appearance


All the best,
Dimo
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Princy
Top achievements
Rank 2
answered on 05 Sep 2008, 01:50 PM
Hi Neil,

You can also try with the following approach.

ASPX:
    <NestedViewTemplate> 
      <div  runat="server" id="Div1"   > 
        <asp:Label ID="Label2" runat="server" Text="My Custom Comment " ></asp:Label> 
      </div> 
    </NestedViewTemplate> 

CS:
protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        foreach (GridDataItem item in RadGrid1.Items) 
        { 
            if (item.Expanded) 
            { 
                PlaceHolder Nestedhldr = (PlaceHolder)(item.OwnerTableView.GetItems(GridItemType.NestedView)[2]).Cells[1].FindControl("NestedViewTemplatePlaceHolder"); 
                System.Web.UI.HtmlControls.HtmlGenericControl div = ((System.Web.UI.HtmlControls.HtmlGenericControl)(Nestedhldr.FindControl("Div1"))); 
                if (item.ItemType == GridItemType.Item) 
                { 
                    div.Style.Value = "background-color:Red"
                } 
                else if (item.ItemType == GridItemType.AlternatingItem) 
                { 
                    div.Style.Value = "background-color:Blue"
                } 
            } 
        } 
   } 


Thanks
Princy.
Tags
Grid
Asked by
Neil N
Top achievements
Rank 1
Iron
Veteran
Iron
Answers by
Dimo
Telerik team
Princy
Top achievements
Rank 2
Share this question
or