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

Per cell display template

3 Answers 30 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mike Chidsey
Top achievements
Rank 1
Mike Chidsey asked on 24 Mar 2010, 08:38 PM
Is there a way to dynamically set the display template for a grid cell at runtime?  My datasource is dynamic, and I need to be able to have 3 different possible templates depending on the data in the row.  The column itself is bound to an object, and contains the values that would be displayed.  Here's what I want to display in a column:

({RelativePortion})% / {Portion}% -- for one type of record  (Relative portion has a gray forecolor)
{Portion}% -- for another type of record
and display - when the portion value is 0 for either type of record

Editing the cell for either type should just be a textbox bound to {Portion}

I think RowLoaded is the event I want to accomplish this with, but I don't know where to start.  I created a Page level resource for the DataTemplate for the first scenario but it didn't display anything, just the typename for the object bound to the column.

Any help would be greatly appreciated.

-Mike

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 25 Mar 2010, 07:55 AM
Hi Mike,

You can use CellTemplate to define a place holder where you can instantiate desired control run-time or you can create your own column, override CreateCellElement and again return desired control.

Kind regards,
Vlad
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
Mike Chidsey
Top achievements
Rank 1
answered on 30 Mar 2010, 01:30 PM
Thanks.  I ended up creating a custom column and overriding the CreateCellElement and CreateCellEditElement methods.
0
Vlad
Telerik team
answered on 30 Mar 2010, 02:11 PM
Hi Mike,

Just to let you know that with our Q1 2010 SP1 (middle of April) you will be able to define custom DataTemplateSelector and StyleSelector for almost every grid DataTemplate and/or Style. These are not available by default in Silverlight however we have our own!

All the best,
Vlad
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.
Tags
GridView
Asked by
Mike Chidsey
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Mike Chidsey
Top achievements
Rank 1
Share this question
or