How to set the culture for GridViewExpressionColumn

8 posts, 0 answers
  1. Julio
    Julio avatar
    8 posts
    Member since:
    Feb 2012

    Posted 22 Jul 2014 Link to this post

    Hi I have a grid with  the following GridViewExpressionColumn 
    <telerik:GridViewExpressionColumn UniqueName="LineTotal"
                                                                                          Header="{Binding ApplicationStrings.LineTotalColumnHeader, Source={StaticResource ResourceWrapper}}"
                                                                                          IsFilterable="False"
                                                                                          IsReadOnly="True"
                                                                                          Expression="QtyOrd * UnitPrice"
                                                                                          DataFormatString="{}{0:C}"
                                                                                          Width="100"
                                                                                          DisplayIndex="6" />

    My application has a dropdown box for Currencies which sets the culture the numeric columns in order to show the data based on that culture without changing the computer regional settings.  All columns are working find but i have issues with the GridViewExpressionColumn column because I can't set the culture for that column.

    I am available to change the culture for other columns with this code.

    With this code:
     if (grdvPODetail == null) return;
                var c1 = (GridViewDataColumn)grdvPODetail.Columns["UnitPrice"];
                var c2 = (GridViewDataColumn)grdvPODetail.Columns["ERPPrice"];
                
                if (c1 != null && c2 != null)
                {
                    var cul = GetCultureInfoBaseOnCurrency();
                    
                    // configure currency for Price
                    var binding = new Binding
                                        {
                                            Path = new PropertyPath("UnitPrice"),
                                            StringFormat = "c",
                                            ConverterCulture = cul
                                        };
                    c1.DataMemberBinding = binding;

                    // configure currency for ERPPrice
                    var binding1 = new Binding
                                        {
                                            Path = new PropertyPath("ERPPrice"),
                                            StringFormat = "c",
                                            ConverterCulture = cul
                                        };
                    c2.DataMemberBinding = binding1;
                    
                }

    Any idea how to achieve what i am trying to do?

  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 23 Jul 2014 Link to this post

    Hello,

    Have you tried respecting the culture for the entire RadGridView (i.e. for each column including the GridViewExpressionColumn)?

    For the purpose you need to configure RadGridView with:
    IsLocalizationLanguageRespected="False". 
    That way every time you change the current culture, the new formats should be applied for all the values 
    populated in RadGridView. You can also check our online documentation for a further reference.

    Regards,
    Didie
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. DevCraft banner
  4. Julio
    Julio avatar
    8 posts
    Member since:
    Feb 2012

    Posted 28 Jul 2014 in reply to Dimitrina Link to this post

    Thanks for the response but still one question pending, How do i set the culture to the Expression Column because when I can't find the Binding option as the other two columns.

    Sorry to bother you I have check the documentation only but i can't find that option.

    Thanks in advance.
  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 29 Jul 2014 Link to this post

    Hi,

    There is not such an option for the GridViewExpressionColumn, it is not a bound column at all.

    Regards,
    Didie
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  6. Julio
    Julio avatar
    8 posts
    Member since:
    Feb 2012

    Posted 22 Aug 2014 in reply to Dimitrina Link to this post

    Hi Didie I have try the option about the property IsLocalizationLanguageRespected = "False" but the expression column still have the computer culture. 

    As you can see in the attached image i can set the Currency symbol for the 2 datacolumns using the code from the original post.

    Is that achievable?

    I have no issues to change the culture of the entire grid as long uses the culture based on the currency that i am using at the moment.





  7. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 26 Aug 2014 Link to this post

    Hi,

    Would you please try setting the culture initially (before RadGridView is loaded):
         public MainPage()
         {
             // Set a culture different of the default system culture
             // It should be respected by the ExpressionColumn
             System.Globalization.CultureInfo cultureInfo =
    new System.Globalization.CultureInfo("fr-CA");
     
             Thread.CurrentThread.CurrentCulture = cultureInfo;
     
             InitializeComponent();
         }


    Having this along with setting IsLocalizationLanguageRespected = "False" should result in formatting all the currencies properly.

    Regards,
    Didie
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  8. Julio
    Julio avatar
    8 posts
    Member since:
    Feb 2012

    Posted 26 Aug 2014 in reply to Dimitrina Link to this post

    Hi Didie, the problem is that I have a dropdown which contains a list of Currencies and I need to change the grid every time the user selects a different currency.

    Sorry to bother you, but I need to achieve that without reloading the page again.


  9. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 27 Aug 2014 Link to this post

    Hi,

    I am afraid changing the culture is not going to take an effect at runtime.
    I can suggest you a bit different approach, which I hope is going to work for you. You can find a demo solution attached.
    The steps to perform are as follows:
    1. Run the attached solution
    2. Set the current culture (by pressing the "Set English Culture" or "Set German Culture" 
    buttons)
    3. Click on the "Set Language on Culture and Rebind" button.

    Regards,
    Didie
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top
DevCraft banner