I want to create a nested Grid and would like to be able to apply some formatting for rows in the master table if there are no child records yet created. I assume I need to put code in the ItemCreated event just not sure where to go from there. Any help would be appreciated.
3 Answers, 1 is accepted
0
Accepted
Princy
Top achievements
Rank 2
answered on 25 Sep 2009, 08:09 AM
Hello AkAlan,
I tried the following code in the PreRender event to achieve a scenario as yours. Probably it may help you:
c#:
Note: The HierarchyLoadMode property of the mastertableview should be either set to "ServerBind"/"Client" for the above code to work.
Hope this helps..
Princy.
I tried the following code in the PreRender event to achieve a scenario as yours. Probably it may help you:
c#:
protected void RadGrid1_PreRender(object sender, EventArgs e) |
{ |
foreach (GridDataItem item in RadGrid1.MasterTableView.Items) |
{ |
if (item.ChildItem.NestedTableViews[0].Items.Count != 0) |
{ |
item.BackColor = System.Drawing.Color.LightGreen; |
} |
else |
{ |
item.BackColor = System.Drawing.Color.LightPink; |
} |
} |
} |
Hope this helps..
Princy.
0
AkAlan
Top achievements
Rank 2
answered on 25 Sep 2009, 05:15 PM
Thanks Princy, That worked like a charm. I will repost the code in VB for others.
Imports Telerik.Web.UI |
Partial Class MyRadGrid |
Inherits System.Web.UI.Page |
Protected Sub RadGrid1_PreRender(ByVal sender As Object, ByVal e As EventArgs) Handles RadGrid1.PreRender |
For Each item As GridDataItem In RadGrid1.MasterTableView.Items |
If item.ChildItem.NestedTableViews(0).Items.Count <> 0 Then |
item.BackColor = System.Drawing.Color.LightGreen |
Else |
item.BackColor = System.Drawing.Color.LightPink |
End If |
Next |
End Sub |
End Class |
0
AkAlan
Top achievements
Rank 2
answered on 25 Sep 2009, 10:56 PM
Hi Princy, I just wanted to follow up on this post since I discovered something interesting. This solution won't work if your HierarchyLoadMode is set to ServerOnDemand. Thanks again for the help.