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

DisplayFormat and ApplyFormatInEditMode

1 Answer 279 Views
GridView
This is a migrated thread and some comments may be shown as answers.
CHRISTIAN
Top achievements
Rank 1
CHRISTIAN asked on 30 May 2011, 11:05 AM
Hi,

I´ve bound a Property like this:

[DisplayFormat(DataFormatString = "{0:F0}", ApplyFormatInEditMode = true, ConvertEmptyStringToNull = false, NullDisplayText = "0")]
decimal value{ get; set; }

to a GridViewDataColumn like this:

<telerik:GridViewDataColumn DataMemberBinding="{Binding Value}" Header="Value"/>

but in Edit Mode it shows to decimal places.
Why is "ApplyFormatInEditMode" not working?

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 30 May 2011, 03:43 PM
Hello CHRISTIAN,

Indeed, the string format is not applied in edit mode. If otherwise, the whole editing for that specific column might be broken. Unfortunately, there are quite many possible scenarios that may lead to damaging the functionality if such support is added. However, we will definitely consider introducing such a feature if being appropriate. 
A possible workaround would be to define a CellEditTemplate and set the StringFormat for the Binding:

<telerik:GridViewDataColumn DataMemberBinding="{Binding StadiumCapacity}"
                                        Header="Stadium">
                <telerik:GridViewDataColumn.CellEditTemplate>
                    <DataTemplate>
                        <TextBox Text="{Binding StadiumCapacity, StringFormat=\{0:F0\}, Mode=TwoWay}" />
                    </DataTemplate>
                </telerik:GridViewDataColumn.CellEditTemplate>
            </telerik:GridViewDataColumn>

Still, whether this solution is appropriate depends entirely on your specific scenario and it is up to you to decide whether it fits into your requirements. 
Do let me know in case you need any further assistance.

All the best,
Maya
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
CHRISTIAN
Top achievements
Rank 1
Answers by
Maya
Telerik team
Share this question
or