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

conditional formatting on detailtable in hierarchy

1 Answer 130 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 13 Oct 2009, 05:55 PM
I've got a 2 level hierarchical grid and I need to set the formatting of certain rows in the child level. I've tried puttting the conditional formatting elements in the itemdatabound event for the overall grid and also in the detailtabledatabind. In each case it has a hard time finding the data element that sets the condition and I get a "cannot find a cell bound to column name..."

Is there an example of how to set the format of a child row based on a data element within that row?

For example if the child row has a data element called "Level" and if level for that row is "3" then the data element called "Name" would be orange...


thanks for any guidance you can give

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 14 Oct 2009, 05:04 AM
Hello Jeff,

You have to differentiate between the ownertableviews and then implement conditional formatting as shown below:
aspx:
<telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" 
runat="server" onitemdatabound="RadGrid1_ItemDataBound"
   <MasterTableView Name="Master"
       <DetailTables> 
         <telerik:GridTableView AutoGenerateColumns="false" Name="Detail" DataSourceID="SqlDataSource2"
          <Columns> 
            <telerik:GridBoundColumn DataField="Level" HeaderText="Level" UniqueName="Level"></telerik:GridBoundColumn> 
            <telerik:GridBoundColumn DataField="Name" HeaderText="Name" UniqueName="Name"></telerik:GridBoundColumn> 
          </Columns> 
         </telerik:GridTableView> 
        .... 

c#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "Detail"
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            if (item["Level"].Text == "3"
            { 
                item["Name"].BackColor = System.Drawing.Color.Crimson; 
            } 
        } 
    } 

Thanks
Princy.
Tags
Grid
Asked by
Jeff
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or