Kendo.culture vs WebAPI/Json

4 posts, 0 answers
  1. Matthijs
    Matthijs avatar
    3 posts
    Member since:
    Jun 2013

    Posted 13 Nov 2015 Link to this post

    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)?

  2. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 17 Nov 2015 Link to this post

    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
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Matthijs
    Matthijs avatar
    3 posts
    Member since:
    Jun 2013

    Posted 18 Nov 2015 in reply to Daniel Link to this post

    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?

  5. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 20 Nov 2015 Link to this post

    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
Back to Top
UI for ASP.NET MVC is VS 2017 Ready