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

RadGridView set template for some cells

2 Answers 74 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Evelyn
Top achievements
Rank 1
Evelyn asked on 19 Oct 2015, 05:22 PM

I have a grid like this:

<telerik:RadGridView x:Name="DataG"ItemsSource="{Binding CamposUsu}"SelectedItem="{Binding Selected}"CanUserReorderColumns="True"CanUserResizeColumns="True"CanUserSortColumns="False"SelectionUnity="FullRow"IsReadyOnly="True"AutoGenerateColumns="False"Loaded="DataG_Loaded" />

 

In the .cs file the method DataG_Loaded:

private void DataG_Loaded(object sender, RoutedEventesArgs e)

{

DataTemplate labelTemplate = new DataTemplate();

FrameworkElementFactory label = new FrameworkElementFactory(typeof(Label));

label.SetValue(Label.ContentProperty, "Unlimited");

labelTemplate.VisualTree = label;

labelTemplate.Seal();this.DataG.Columns[7].CellTemplate = labelTemplate;

//this column 7 is a column called "Vl." with double values

}

Well, when I comment the method DataG_Loaded, my grid is fulfilled correctly with the objects I created on my viewmodel. When I uncomment the method, the column "Vl." that had values like "93.5", "108.9"... is all fulfilled with the value "Unlimited".
This was already expected. I want only the cells that the value is > 100.0 to turn to the string "Unlimited".

Is there any way of doing this?

2 Answers, 1 is accepted

Sort by
0
Evelyn
Top achievements
Rank 1
answered on 19 Oct 2015, 05:23 PM
Oh, the example for what I want is attached to the post
0
Martin
Telerik team
answered on 22 Oct 2015, 01:18 PM
Hello Evelyn,

To achieve the desired behavior you can use IValueConverter on the specific GridViewDataColumn.
For your convenience, I prepared an example to demonstrate you what I have in mind. Please take a look at the implementation and consider how this approach fits your scenario.

Regards,
Martin Vatev
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
Evelyn
Top achievements
Rank 1
Answers by
Evelyn
Top achievements
Rank 1
Martin
Telerik team
Share this question
or