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
0
Hello Rachel,
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.
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
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.
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
Hello,
Regards,
Didie
the Telerik team
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"
);
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