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

Change header text of Radgrid hierarchy at Detail table levels

1 Answer 350 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Aret
Top achievements
Rank 1
Aret asked on 30 May 2014, 01:00 PM
I have a Radgrid with auto generated columns = "True" and I would like to change the header text programmatically at the Detail table levels when the radgrid loads at page load.  How would I accomplish this?  I figured simply utilizing the code shown below would work, but it doesn't do anything.  The page just loads with no errors, and the text does not change on the header.  However, when I change the text programmatically in the root level of the radgrid it works, but does not work at the detail levels.  Please Help!

'''I tried this code in the PreRender and ItemDataBound Events.  But it does not work. Text does not change.... 

Radgrid_CRGList.MasterTableView.DetailTables(1).DetailTables(0).GetColumn("UniqueName").HeaderText = "Custom Header Text"

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 02 Jun 2014, 03:45 AM
Hi Aret,

You can try the following code snippet in the PreRender event to set HeaderText.

VB:
Protected Sub RadGrid1_PreRender(sender As Object, e As EventArgs)
    'Setting HeaderText
        '1st level of Hierarchy
    RadGrid1.MasterTableView.DetailTables(0).GetColumn("StateID").HeaderText = "Custom Header Text"
         
        '2nd level of Hierarchy   
    RadGrid1.MasterTableView.DetailTables(0).DetailTables(0).GetColumn("DistrictID").HeaderText = "Custom Header Text" 
End Sub

Thanks,
Princy
Kapil
Top achievements
Rank 1
Iron
commented on 27 May 2021, 08:20 PM

I m trying to do same thing unable to find preRender event
Vessy
Telerik team
commented on 01 Jun 2021, 09:13 AM

Hi Kapil, 

Which version of the controls are you using?

You can attach a handler to the Grid's PreRender event like follows:

ASPX:

        <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" Width="800px" OnPreRender="RadGrid1_PreRender">
            ...
        </telerik:RadGrid>

Tags
Grid
Asked by
Aret
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or