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

FormatString for Editors in GridView

6 Answers 85 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rachel
Top achievements
Rank 2
Rachel asked on 15 Sep 2009, 06:58 AM
Hello,
I use formatstrings to format the data in the columns of my gridview, but when the user begins to edit a cell, the formatstring is not applied.  This means sometimes many zeros can show, effectively filling the editor with zeros and making editing cumbersome.  Is there a way to apply a formatstring to what is shown in the editor?

Thanks in advance!
Rachel

6 Answers, 1 is accepted

Sort by
0
Stefan Dobrev
Telerik team
answered on 17 Sep 2009, 12:33 PM
Hello Rachel,

We currently did not support this scenario by default. However you can create a CellEditTemplate to handle this. Here is an example GridViewDataColumn with custom edit template that handles your case:
<telerik:GridViewDataColumn Header="Number" DataMemberBinding="{Binding Number}" DataFormatString="{}{0:000}"
    <telerik:GridViewDataColumn.CellEditTemplate> 
        <DataTemplate> 
            <TextBox Text="{Binding Number, Converter={StaticResource StringFormatter}, ConverterParameter='{0:000}'}"  /> 
        </DataTemplate> 
    </telerik:GridViewDataColumn.CellEditTemplate> 
</telerik:GridViewDataColumn> 

I'm attaching the sample project for your reference.

Hope this helps.

Sincerely yours,
Stefan Dobrev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Celeste
Top achievements
Rank 1
answered on 05 Nov 2009, 04:32 PM
I downloaded your example but after I edit a cell and when it lost focus, I can see old value. Is binding working?


0
Stefan Dobrev
Telerik team
answered on 09 Nov 2009, 10:29 AM
Hello Celeste,

You should set the the mode of the binding to TwoWay in order to get the updated value back into the grid. Please note that you should implement the convert back method of the StringFormatConverter.

Greetings,
Stefan Dobrev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Marc Roussel
Top achievements
Rank 2
answered on 01 May 2013, 10:47 PM
How do I achieve this with date that should be MM-dd-YYYY when the user select English and dd-MM-yyyy when the user selected French at runtime ?
0
Dimitrina
Telerik team
answered on 06 May 2013, 02:12 PM
Hello,

This formatting is language specific and it will be changed once you set another Language for the GridView. For example:

this.clubsGrid.Language =  XmlLanguage.GetLanguage("en");

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Marc Roussel
Top achievements
Rank 2
answered on 06 May 2013, 04:10 PM
That's exactly what I found and it works all right.  Thank you
Tags
GridView
Asked by
Rachel
Top achievements
Rank 2
Answers by
Stefan Dobrev
Telerik team
Celeste
Top achievements
Rank 1
Marc Roussel
Top achievements
Rank 2
Dimitrina
Telerik team
Share this question
or