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

Accessing columns by name rather than index

4 Answers 68 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Al
Top achievements
Rank 1
Iron
Iron
Iron
Al asked on 29 Jun 2010, 09:44 AM
Hi,

Please tell me how to achieve something like this:

RadGrid1.MasterTableView.AutoGeneratedColumns[

 

"somecol"].HeaderText = "My Column";

 


In this instance I only want to set the column header text but say i want to programmatically access a column for any reason I can't see a method to allow me to do this by key and it is impossible to know the index of the column

4 Answers, 1 is accepted

Sort by
0
Accepted
Pavlina
Telerik team
answered on 29 Jun 2010, 10:20 AM
Hello Al,

You can customize the properties of grid columns at runtime by providing a handler for the grid's ColumnCreated/ PreRender event and using a column UniqueName property. For more information you can refer to the help article below:
Using columns(Customizing columns programmatically section)

I hope this gets you started properly.

Kind regards,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Al
Top achievements
Rank 1
Iron
Iron
Iron
answered on 29 Jun 2010, 10:49 AM
Thanks Pavlina the ColumnCreated event works just fine for customizing AutoGeneratedColumns.

Is it possible to access an auto generated column by name after the grid has been rendered?

eg. GridColumn gc = RadGrid1.MasterTableView.AutoGeneratedColumns["somecol"];
0
Pavlina
Telerik team
answered on 29 Jun 2010, 02:14 PM
Hello Al,

To achieve your goal you could handle on ItemDataBound/ItemCreated event. For more information about how to access AutoGeneratedColumns you can also examine this help topic.

Kind regards,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Al
Top achievements
Rank 1
Iron
Iron
Iron
answered on 29 Jun 2010, 02:29 PM
Thanks Pavlina, that info looks like it may be what I was after. My main question about the column titles has been answered above.
Tags
Grid
Asked by
Al
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Pavlina
Telerik team
Al
Top achievements
Rank 1
Iron
Iron
Iron
Share this question
or