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

How to read datatemplate name from gridview column definition

1 Answer 59 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Karel
Top achievements
Rank 1
Karel asked on 06 Aug 2014, 08:22 AM
Hi,

I am trying to create gridview's columns dynamically and it works ok, I have my own object with all properties I want to set on columns. One of them is CellTemplateName so I can set column.CellTemplate = Resources[columnDefinition.CellTemplateName] as DataTemplate and it works ok.

The problem is when I want to read and save column definitions from gridview. Then I don't know how to get this CellTemplateName. I tried to get column.CellTemplate.DataTemplateKey but it is null.

Can you help what is the right way how to get the correct resource name of the cellTemplate?

Thank you,
Karel Bem

1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 07 Aug 2014, 08:56 AM
Hi Karel,

I am afraid there is not such a property holding the name/key of the DataTemplate set as column's CellTemplate available.
As to Binding columns dynamically, you can check this github example on Binding columns from view model which allows dynamically adding and removing columns. 
Although GitHub is a very well-known platform we saw a better and easier approach for reviewing our examples developing our brand new SDK Samples Browser. You can also use it to review the examples.

Regards,
Didie
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
GridView
Asked by
Karel
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or