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

Problem with hierarchy and detail tables

1 Answer 114 Views
Grid
This is a migrated thread and some comments may be shown as answers.
License Developer
Top achievements
Rank 1
License Developer asked on 27 Feb 2009, 09:15 AM
Hello,
I have a rad grid in a usercontrol with 3 levels of hierarchy as shown bellow, 

<rad:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" OnItemDataBound="OnGridItemDataBound" 
    EnableViewState="true">  
    <MasterTableView DataSourceID="SqlDataSource1" DataKeyNames="SpecialismeNaam" AllowMultiColumnSorting="True" 
        EnableViewState="true">  
        <DetailTables> 
            <rad:GridTableView DataKeyNames="CareType" DataSourceID="SqlDataSource2" Width="100%" 
                runat="server">  
                <ParentTableRelation> 
                    <rad:GridRelationFields DetailKeyField="SpecialismeNaam" MasterKeyField="SpecialismeNaam" /> 
                </ParentTableRelation> 
                <DetailTables> 
                    <rad:GridTableView DataKeyNames="Indicator" DataSourceID="SqlDataSource3" Width="100%" 
                        runat="server">  
                        <ParentTableRelation> 
                            <rad:GridRelationFields DetailKeyField="CareType" MasterKeyField="CareType" /> 
                        </ParentTableRelation> 
                    </rad:GridTableView> 
                </DetailTables> 
            </rad:GridTableView> 
        </DetailTables> 
    </MasterTableView> 
</rad:RadGrid> 


in the OnItemDataBound event handler, I replace the value of specific column cells with a suitable image,

        protected void OnGridItemDataBound(object sender, Telerik.WebControls.GridItemEventArgs e)  
        {  
            GridDataItem item = e.Item as GridDataItem;  
            if (item == null)  
            {  
                return;  
            }  
 
            if (item["Trend"] == null)  
            {  
                return;  
            }  
 
            int trenValue;  
            if (!int.TryParse(item["Trend"].Text, out trenValue))  
            {  
                return;  
            }  
 
            // Display image  
            item["Trend"].Controls.Add(GetCellArrowImage(trenValue));  
        } 


the images are displayed well, but the problem is when I expand a detail table, the images in the parent table disappear and appears in the child table, I want them to be displayed in all hierarchy levels.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 02 Mar 2009, 01:32 PM
Hi,

Try setting the Name property for the Master and Detail table. So that you can identify which table you are dealing with in the ItemDataBound event using the Name property and then set the image accordingly.
Distinguish grid rows in hierarchy on ItemCreated/ItemDataBound

Thanks


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