RadGridView set template for some cells

3 posts, 0 answers
  1. Evelyn
    Evelyn avatar
    18 posts
    Member since:
    Mar 2015

    Posted 19 Oct 2015 Link to this post

    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. Evelyn
    Evelyn avatar
    18 posts
    Member since:
    Mar 2015

    Posted 19 Oct 2015 in reply to Evelyn Link to this post

    Oh, the example for what I want is attached to the post
  3. Martin Vatev
    Martin Vatev avatar
    131 posts

    Posted 22 Oct 2015 Link to this post

    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.

    Martin Vatev
    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
Back to Top