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

Hierarchical RadGrid Ignores Header Text Set in Code-Behind

1 Answer 76 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 1
Brian asked on 24 Jul 2014, 05:57 PM
Telerik version: 2011.2.915.40

I am trying to set the header text for one of the columns in my hierarchical grid.  I am using the default HierarchyLoadMode (ServerOnDemand).

My original attempt was to call a recursive function on Page_Load that set the header text for each level in the hierarchy.  This works fine until you expand level 3, at which point the header text on level 2 displays the value set in the .aspx instead of the value I am setting in the code-behind.  Based on other posts I have seen in this forum, I have also tried setting the header text in the ItemDataBound event of my grid and in the PreRender of the grid.  Setting the text in the ItemDataBound works for whatever level was just loaded (first level initially, then second level when you expand the first, etc.) but the other levels display the value set in the .aspx.  Setting the text in the PreRender of the grid doesn't seem to work at all.

Where is the correct place to set header text for a hierarchical RadGrid so that it works when the grid updates?

Thanks,
Brian

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 Jul 2014, 02:41 AM
Hi Brian,

You can use the PreRender event to set the HeaderText, please try the following code snippet.

C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
    RadGrid1.MasterTableView.DetailTables[0].GetColumn("ColumnUniqueName").HeaderText = "Custom Header Text";//1st level of Hierarchy
    RadGrid1.MasterTableView.DetailTables[0].DetailTables[0].GetColumn("ColumnUniqueName").HeaderText = "Custom Header Text";//2nd level of Hierarchy
    RadGrid1.Rebind();    
}

Thanks,
Shinu
Tags
Grid
Asked by
Brian
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or