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

Kendo.culture vs WebAPI/Json

3 Answers 123 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Matthijs
Top achievements
Rank 1
Matthijs asked on 13 Nov 2015, 11:40 AM

Hello,

I have a Razor build-ed grid which the datasource is WebAPI. The model contains a decimal field.

In Dutch (nl-NL) the separated character for decimal is comma instead of dot.

When setting in JS the Kendo.culture to "nl-NL", and the input contains a comma as ​decimal separated character, the ​created JSON model from Kendo Grid to the WebAPI contains also the comma instead of dot. At server-side the input will bbe set without decimal.

 Example: 34,45 is in the JSON  and gives 3445. 

 If the culture is removed, the JSON contains the dot and all works fine.

Question is, can I force the generated JSON model to handle input always as default culture (dot as decimal separated)?

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 17 Nov 2015, 11:27 AM
Hello,

This is a known issue that is logged in our system for further investigation. The WebAPI uses the invariant culture formats to parse the values but the webapi dataSource serializes dates and numbers based on the current culture. The simplest option to avoid the problem is to use the request data function to convert the numbers to string e.g.
.Update(update => update.Url(Url.HttpRouteUrl("DefaultApi", new { controller = "ControllerName", id = "{0}" })).Data("serialize"))
function serialize(data) {
    for (var field in data) {
        if (typeof data[field] === "number") {
            data[field] = data[field].toString();
        }
    }
}



Regards,
Daniel
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Matthijs
Top achievements
Rank 1
answered on 18 Nov 2015, 09:31 AM

Thank you Daniel. This show the value with the (Dutch) comma in row.

But when the row switch to edit, the value show the dot instead of comma.

Is there a manner to change this also to comma as decimal seperator?

0
Daniel
Telerik team
answered on 20 Nov 2015, 08:50 AM
Hello again,

What editor template are you using for the field? The editor should be a numerictextbox in order for the value in edit mode to be formatted based on the culture.

Also, the problem with the format used by the webapi dataSource has been fixed and the fix will be available in the next internal build.

Regards,
Daniel
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Matthijs
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Matthijs
Top achievements
Rank 1
Share this question
or