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

How to set the culture for GridViewExpressionColumn

7 Answers 461 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Julio
Top achievements
Rank 1
Julio asked on 22 Jul 2014, 08:58 PM
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?

7 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 23 Jul 2014, 10:40 AM
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.
 
0
Julio
Top achievements
Rank 1
answered on 28 Jul 2014, 11:26 PM
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.
0
Dimitrina
Telerik team
answered on 29 Jul 2014, 11:47 AM
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.
 
0
Julio
Top achievements
Rank 1
answered on 22 Aug 2014, 06:39 PM
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.





0
Dimitrina
Telerik team
answered on 26 Aug 2014, 02:30 PM
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.
 
0
Julio
Top achievements
Rank 1
answered on 26 Aug 2014, 02:35 PM
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.


0
Dimitrina
Telerik team
answered on 27 Aug 2014, 08:29 AM
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.
 
Tags
GridView
Asked by
Julio
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Julio
Top achievements
Rank 1
Share this question
or