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

[Solved] Need recommendation for dynamically defining columns

3 Answers 88 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Alessandro
Top achievements
Rank 1
Alessandro asked on 03 Feb 2011, 11:10 PM
We are using a Grid to to represent different data types. Therefore, the Grid it bound to its source dynamically and the column generation is automatic. Well, this doesn't provide for must customization on the columns.

What would you recommend in terms of dynamically specifying the column definition based on the data to which the Grid is bound? I've already figured out how to use selectors for the detail views. Can something like that be done for the grid?

So, these seem to be my options:

1. Pass some sort of definition to the grid and programatically construct the column definitions.
2. Define three different grids (each for the datatype is represents).

Any other ideas?
 
-- xavier

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 04 Feb 2011, 07:33 AM
Hello,

You can customize auto-generated columns using AutoGeneratingColumn event. 

Greetings,
Vlad
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Alessandro
Top achievements
Rank 1
answered on 04 Feb 2011, 01:15 PM
So basically, I'd first check to see if my column is one of those that needs a specific type of styling. For instance, some of our columns are an enumeration that should render a particular image based on the value in the column.

I would have to dynamically assign the column's style/template definition so you're saying this is the right place to do that? The only examples I've seen of customizing a column's style do it in Xaml. Do you have an example of how to do this in code-behind based on a pre-existing definition of the column's template?

 -- xavier
0
Vlad
Telerik team
answered on 04 Feb 2011, 01:41 PM
Hello,

Setting column properties in code will work exactly the same as in XAML - nothing special. In this event you can use e.Column to access desired property. 

Regards,
Vlad
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Tags
GridView
Asked by
Alessandro
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Alessandro
Top achievements
Rank 1
Share this question
or