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

Formatting Currency in GridViewComboBoxColumn

5 Answers 183 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Greg
Top achievements
Rank 1
Greg asked on 06 Mar 2015, 02:36 PM
I have a GridViewComboBoxColumn that displays a dollar amount. If I don't try to format it, it works and displays "100000.00" for underlying data of 100000.

However, I want this to display as "$100,000.00". Nothing I've tried has worked. This shouldn't be difficult...

<telerik:GridViewComboBoxColumn Width="Auto"
                                DataMemberBinding="{Binding ProjectPhaseLoanId}"
                                DisplayMemberPath="ApplicationAmount"
                                Header="Loan/Amount"
                                ItemsSource="{Binding ProjectPhase.Loans}"
                                SelectedValueMemberPath="Id" />

5 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 09 Mar 2015, 01:46 PM
Hi,

Have you tried configuring the GridViewComboBoxColumn with 
DataFormatString="{}{0:C2}"?

Regards,
Dimitrina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Greg
Top achievements
Rank 1
answered on 09 Mar 2015, 02:05 PM
Yes, I've tried that. That crashes the app with an error of "Input string was not in a correct format.".
0
Dimitrina
Telerik team
answered on 11 Mar 2015, 03:23 PM
Hi,

I am sorry to hear this does not work either. Such an error indicates that the expected format is different than the format of the entered value. In order to avoid any misunderstandings may I ask you to isolate the exact case in a demo project with your specific implementation and send it to us via a new support ticket? 
You can also refer to the following blog post on how to isolate a problem. That way I will check it locally and try suggesting a solution for this exact case.

Regards,
Dimitrina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Chris Andrews
Top achievements
Rank 1
answered on 05 Jun 2016, 11:26 PM

Hello,

I see this post is over a year old, but I am also experiencing the same issue.  I created a very basic app to isolate the issue and was successful at doing so.

In the attached solution, if I add DataFormatString="{}{0:C}" to the GridViewComboBoxColumn, I get the same error reported by Greg.

Can you please take a look and let me know if there are other solutions to this, or if this is indeed a bug.  I have tested with the latest release, as well as the latest internal build with same results.

Here is a link to the solution: DataFormatString.zip

Thanks,

Chris

 

0
Yoan
Telerik team
answered on 08 Jun 2016, 02:40 PM
Hi Chris,

Actually, the DataFormat string is not respected by ComboBox column, because of the lookup logic which has to be done. What you can try in this case would be to predefine the ItemTemplate and apally and converter like so:
<telerik:GridViewComboBoxColumn DataMemberBinding="{Binding CountryId}"
                                            UniqueName="Country"
                                            ItemsSource="{Binding Countries,Source={StaticResource MyViewModel}}"
                                            SelectedValueMemberPath="Id"                                                   
                                            DisplayMemberPath="Name" >
                <telerik:GridViewComboBoxColumn.ItemTemplate>
                    <DataTemplate>                         
                            <TextBlock Text="{Binding Name,Converter={StaticResource conv}}"  Grid.Column="1"></TextBlock>                        
                    </DataTemplate>
                </telerik:GridViewComboBoxColumn.ItemTemplate>
            </telerik:GridViewComboBoxColumn>

You can check the section "Templating GridViewComboBoxColumn" from this help article.

Regards,
Yoan
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
GridView
Asked by
Greg
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Greg
Top achievements
Rank 1
Chris Andrews
Top achievements
Rank 1
Yoan
Telerik team
Share this question
or