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

[Solved] Apply User-Defined Color to NestedRadGrid Items

2 Answers 78 Views
Grid
This is a migrated thread and some comments may be shown as answers.
kunal patel
Top achievements
Rank 1
kunal patel asked on 07 Dec 2009, 07:30 AM
Hello,

         I am using NestedRadGrid in my application.
         The MasterTableGrid is bound inside NeedDataSource event.
         Also, the NestedRadGrid is bound on the the RadGrid1_DetailTableDataBind() Event.

         I am getting data from the database, in which I have one column COMPLETE/INCOMPLETE.
         So, I want to mark that column text as BLUE when COMPLETE & RED when INCOMPLETE in NestedRadGrid.


        Please reply me as Soon as Possible,




Thanks,
Kunal Govani
       

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 07 Dec 2009, 08:27 AM
Hello Kunal,

You can traverse through the items in the detail table using its name property and then apply conditional formatting to the child table rows:
aspx:
<telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" AutoGenerateColumns="false" runat="server" OnItemDataBound="RadGrid1_ItemDataBound"
    <MasterTableView DataSourceID="SqlDataSource1" Name="Master"
          <DetailTables> 
               <telerik:GridTableView AutoGenerateColumns="false" DataSourceID="SqlDataSource2" Name="Detail" runat="server">                            
                          

c#:
 protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "Detail"
        { 
            GridDataItem dataItem = (GridDataItem)e.Item; 
            if (dataItem["ColumnDataFieldName"].Text == "InComplete"
                dataItem["ColumnDataFieldName"].BackColor = System.Drawing.Color.Red; 
            else 
                dataItem["ColumnDataFieldName"].BackColor = System.Drawing.Color.Blue; 
        } 
    } 

Thanks
Princy.
0
kunal patel
Top achievements
Rank 1
answered on 07 Dec 2009, 08:38 AM
Thanks Princy,

            I got the output with this code.



Thanking You,
Kunal
Tags
Grid
Asked by
kunal patel
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
kunal patel
Top achievements
Rank 1
Share this question
or