Search code examples
devexpressdevexpress-mvcdevexpress-wpf

How can I define value´s format of a cell based in a variable?


I would like to set the format of a cell based on another value: In my example if value1 = "percent", value2 will appear like 10%. If value1 = "two", value2 will appear line 10.00, and so on...

<dxg:FormatCondition Expression="[value1] = 'percent'" FieldName="value2">
    <dxg:Format />
</dxg:FormatCondition> 

Is there any kind of mask in or setting the value of the cell (using Eval or similar) for achieving this?

Thanks guys...

EDITED: Maybe could be set here...

<TextBlock Name="value2_name" Text="{Binding Data.value2}"/> 

Solution

  • Finally I got it.

    The idea could be handle all from server-side.

    Like:

    -- XAML --

    <dxg:GridColumn FieldName="Limit" AllowEditing="True" Width="80">
                        <dxg:GridColumn.CellTemplate>
                            <DataTemplate>
                                <Border Background="#FFFF99">
                                    <dxe:SpinEdit Name="PART_Editor" IsEnabled="{Binding Data.IsEnabledLimit}" Mask="{Binding Data.MaskLimit}" MaskType="Numeric" MaskUseAsDisplayFormat="True"/>
                                </Border>
                            </DataTemplate>
                        </dxg:GridColumn.CellTemplate>
    

    -- CONTROLLER --

        public string MaskLimit
        {
            get 
            {
                if (Designation == Constant.HEADER_RF)
                {
                    return "###.##%";
                }
                else
                {
                    return "###.######";
                }
            }
        }
    

    Hoping it helps...