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

Updating headers in ItemDataBound breaks sorting

2 Answers 239 Views
Grid
This is a migrated thread and some comments may be shown as answers.
bdrennen
Top achievements
Rank 1
bdrennen asked on 18 Jan 2019, 10:10 PM

I have a RadGrid that's losing the ability to sort columns by clicking the column header. I've narrowed it down to some code in my ItemDataBound method that updates the header text. If I remove this code, clicking the column headers works properly. But when I put it back, sorting is disabled. 

Here's my grid:

<telerik:RadGrid ID="RadGrid1" runat="server"
    AllowSorting = "true"
 
    OnNeedDataSource="RadGrid1_NeedDataSource"
    OnItemDataBound="RadGrid1_ItemDataBound"
    OnPreRender="RadGrid1_PreRender"
     
    RenderMode="Classic"
    Skin="Windows7">
</telerik:RadGrid>

 

Here's my ItemDataBound method:

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) {
    if (e.Item is GridHeaderItem) {
        GridHeaderItem header = (GridHeaderItem)e.Item;
        header["MONTH_NAME_LONG"].Text = "Month";
    }
}

 

Any idea why this is happening?

2 Answers, 1 is accepted

Sort by
0
Accepted
Eyup
Telerik team
answered on 23 Jan 2019, 08:31 AM
Hi,

You can check the explanation and use the solution provided here to resolve the issue:
https://www.telerik.com/support/kb/aspnet-ajax/grid/details/changing-radgrid-column-header-text-when-sorting-is-enabled

I hope this will prove helpful.

Regards,
Eyup
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
bdrennen
Top achievements
Rank 1
answered on 23 Jan 2019, 05:44 PM
Aha! Thank you very much--the second solution worked for me.
Tags
Grid
Asked by
bdrennen
Top achievements
Rank 1
Answers by
Eyup
Telerik team
bdrennen
Top achievements
Rank 1
Share this question
or