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

Hierarchical grid change header depending on parent data

2 Answers 57 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joerg
Top achievements
Rank 1
Joerg asked on 24 Oct 2008, 08:55 AM
I need to change the header of a column in detailview to a data value of the parent row. I tried to achive this with the following code in the ItemDataBound-event, but it does not work.

        If e.Item.OwnerTableView.Name = "Level2" And e.Item.ItemType = Telerik.WebControls.GridItemType.Header Then 
 
            Dim header As Telerik.WebControls.GridHeaderItem = CType(e.Item, Telerik.WebControls.GridHeaderItem)  
            header("Rabatt").Text = e.Item.OwnerTableView.ParentItem.Cells(5).Text  
 
        End If 

Anyone got an idea?

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 24 Oct 2008, 09:39 AM
Hi,

Try out the following code snippet in the PreRender event to achieve the desired scenario.

VB:
Protected Sub RadGrid1_PreRender(sender As Object, e As EventArgs) 
    For Each parentitem As GridDataItem In RadGrid1.MasterTableView.Items 
        If parentitem.Expanded Then 
            Dim strTxt As String = parentitem("columnUniqueName").Text 
            Dim childtable As GridTableView = DirectCast(parentitem.ChildItem.NestedTableViews(0), GridTableView) 
            For Each childHeader As GridHeaderItem In childtable.GetItems(GridItemType.Header) 
                childHeader("Rabatt").Text = strTxt 
            Next 
        End If 
    Next 
End Sub 
 


Cheers
Shinu.
0
Joerg
Top achievements
Rank 1
answered on 24 Oct 2008, 10:50 AM
Thanks a lot! This works fine!
Tags
Grid
Asked by
Joerg
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Joerg
Top achievements
Rank 1
Share this question
or