Formatting Currency in GridViewComboBoxColumn

6 posts, 0 answers
  1. Greg
    Greg avatar
    35 posts
    Member since:
    Sep 2013

    Posted 06 Mar 2015 Link to this post

    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" />
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 09 Mar 2015 Link to this post

    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.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Greg
    Greg avatar
    35 posts
    Member since:
    Sep 2013

    Posted 09 Mar 2015 in reply to Dimitrina Link to this post

    Yes, I've tried that. That crashes the app with an error of "Input string was not in a correct format.".
  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 11 Mar 2015 Link to this post

    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.

     
  6. Chris Andrews
    Chris Andrews avatar
    41 posts
    Member since:
    Mar 2010

    Posted 05 Jun Link to this post

    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

     

  7. Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 08 Jun Link to this post

    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.
Back to Top
UI for WPF is Visual Studio 2017 Ready