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

[Solved] Wrong localization DataType Double after ajax postback

6 Answers 140 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Mario van de Pol
Top achievements
Rank 1
Mario van de Pol asked on 07 May 2010, 10:55 AM
Hello, I have a problem with displaying and editing Doubles. On first load things are fine, I get a nicely formatted currency, with the correct (Dutch) separator ",". However as soon as I make an Ajax postback or press Edit, the Dutch localization is lost. Then I get a "." separator. Clientside validation will now only accept values with a "." separator, but serverside a "," separator is expected, leading to a null value. Is this a bug or am I missing something?

View example:

<%--not passing in Model will lead straight to an ajaxbound grid, without 
the correct localization (in my (Dutch) case will show 150.99 instead of (the correct value) 150,99.
Passing Model will now only cause the localization to be correct on the first load.
After, for example, sorting Dutch localization is lost.

Formatting is lost as well, but I believe that is a known issue.
--%>
<%= Html.Telerik().Grid<Mvc2Application.Models.OrderViewModel>(Model)
        .Name("Grid")
            .DataKeys(keys =>
            {
                keys.Add(o => o.OrderID);
            })
        .Columns(columns =>
        {
            columns.Bound(o => o.OrderID);
            columns.Bound(o => o.OrderDate);
            columns.Bound(o => o.ShipAddress);
            columns.Bound(o => o.TestAmount).Format("{0:C}");
            columns.Command(commands =>
            {
                commands.Edit();
            }).Width(180);
        })
        .Sortable()
        .Localizable("nl-NL")
        .DataBinding(dataBinding => dataBinding.Ajax()
            .Select("Select","Home")
            .Update("Update", "Home")
            )
        .Filterable()
        .Pageable()
%>

<% Html.Telerik().ScriptRegistrar().Globalization(true); %>

6 Answers, 1 is accepted

Sort by
0
Accepted
Georgi Krustev
Telerik team
answered on 07 May 2010, 04:48 PM
Hi Mario van de Pol,

Currently we do not support number formatting on the client (using Ajax binding). Hence when you sort, page or etc. the grid will render number without culture formatting. As a work around I can suggest you always to use server binding.

Nevertheless I am glad to inform you that number formatting is already implemented and will be included in the next official release of our components.

All the best,
Georgi Krustev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Mario van de Pol
Top achievements
Rank 1
answered on 10 May 2010, 09:28 AM
Thanks for clearing that out. There is also a similar issue with Boolean values. On first load they are bound to checkboxes, but after ajax postback they show boolean string values ("false" or "true"). Will that also be addressed?
0
Atanas Korchev
Telerik team
answered on 10 May 2010, 09:35 AM
Hi Mario van de Pol,

This occurs because of Display templates. For server binding display templates are used (which in ASP.NET MVC 2 is disabled checkbox). For ajax binding the raw value is shown. Initially your grid is server bound, then ajax. If you want "true/false" to always be shown set the Format of your column to "{0}". This will override the display template and the raw data will be shown. If you want to show checkboxes for ajax binding scenarios you should set the ClientTemplate of the boolean column:

columns.Bound(p => p.Discontinued).Width(100)
                   .ClientTemplate("<input type='checkbox' disabled='disabled' name='Discontinued' <#= Discontinued? \"checked='checked'\" : \"\" #>' />");


Regards,
Atanas Korchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Mario van de Pol
Top achievements
Rank 1
answered on 10 May 2010, 10:08 AM
Thanks! Not bad, an answer within 6 minutes on a monday! q-_-p
0
Jeroen Eikmans
Top achievements
Rank 1
answered on 20 Oct 2011, 10:36 AM
I think this is still applicable to the current version i'm using (2011.2.915.0)

In my app I have a Grid with Ajax binding. The localization is set to nl-NL.
One Currency column has Format set to {0:c} but in the Grid I see $ instead of €
The same thing for DateTime fields. They're also displayed in US style.

A test with a server binding does show the correct DateTimeFormat and the correct Currency.

I also made a GridLocalization.nl-NL.resx file with all dutch values. This is working fine!

Any advice?

PS. I uploaded the nl-NL localization resources so perhaps Telerik can add them to the MVC Installation.
0
Atanas Korchev
Telerik team
answered on 21 Oct 2011, 07:42 AM
Hello Roel Martens,

Thank you for submitting Dutch localization! I have updated your Telerik points as a token of our gratitude.

Enabling localization would only translate the grid message to Dutch. Globalization however would globalize the data - such as using the euro instead of dollar. Make sure globalization is enabled at ScriptRegistrar level:

<%= Html.Telerik().ScriptRegistrar().Globalization(true) %>

Also make sure the CurrentCulture setting is properly set to nl-NL - this is also required for the proper globalization.

Regards,
Atanas Korchev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
Grid
Asked by
Mario van de Pol
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Mario van de Pol
Top achievements
Rank 1
Atanas Korchev
Telerik team
Jeroen Eikmans
Top achievements
Rank 1
Share this question
or