Changing column header text for columns generated dynamically at runtime

1 Answer 213 Views
Grid
jmillar
Top achievements
Rank 1
jmillar asked on 10 Dec 2022, 01:14 PM

Hi there;

I have a grid bound to a datasource, and the grid is set to dynamically generate columns at runtime (i.e. show whatever the data source returns).  I need to change the caption on some of those columns, however.  I tried access grid.MasterTableView.Columns in both grid_Databound and Page_PreRender, but it's empty in all cases.  What am I missing?

Thanks,

Jason

1 Answer, 1 is accepted

Sort by
0
Valentin Dragnev
Telerik team
answered on 14 Dec 2022, 03:50 PM

Hi Jason,

To change the column header text of the autogenerated columns, one way is to use the OnColumnCreated server event.

In the attached archive you will find a fully runnable GRID sample with an attached dummy database and autogenerated columns. At the code behind inside the RadGrid1_ColumnCreated event, you can set the different names for the columns.  

Please refer to this article for more clarification:

Hope the provided information was helpful. 

 

Regards,
Valentin Dragnev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Grid
Asked by
jmillar
Top achievements
Rank 1
Answers by
Valentin Dragnev
Telerik team
Share this question
or