0

I have the following problem. Working with application in polish Culture, scripts kendo.culture.pl-PL.min.js and kendo.messages.pl-PL.min.js are loaded correctly, I can check it in console: after issuing kendo.culture() I get object {name: "pl-PL", numberFormat: Object,....

In my view I'm using

@Html.Kendo().NumericTextBoxFor(m => m.LimitMax)

where LimitMax is decimal with the value of 200. When my view renders I can see no value in KendoNumericTextBox - if I want to retreive it, I get null.

I tried to investigate the problem and I found that: 1) the input generated by the helper is like this:

<input data-val="true" data-val-number="Pole musi być liczbą." data-val-range="Pole musi być z zakresu od 0 do 2147483647." data-val-range-max="2147483647" data-val-range-min="0" id="LimitMax" name="LimitMax" type="number" value="200,0000" />

2) It is jQuery that gives me the following message in the console:

The specified value "200,0000" is not a valid number. The value must match to the following regular expression: -?(\d+|\d+\.\d+|\.\d+)([eE][-+]?\d+)?

I can get around the problem by setting :

@Html.Kendo().NumericTextBoxFor(m => m.LimitMax).Culture("en-US")

but this way does not seem right to me.

Could you please provide any ideas how to solve this problem?

vanpersil
  • 764
  • 1
  • 8
  • 26
  • What culture you have on your mvc app? In `Thread.CurrentThread.CurrentCulture` and `Thread.CurrentThread.CurrentUICulture`? Is both of them are also set to `pl-PL`? If not try to set it and check if it helps. – Jarosław Kończak Apr 28 '17 at 16:35
  • It is properly set to pl-PL, and that is why the decimal value is rendered by Razor to 200,000. To double check it, I rendered @Thread.CurrentThread.CurrentCulture in the view and it says pl-PL – vanpersil Apr 29 '17 at 07:40

1 Answers1

0

Unfortunately I haven't found any solution neither by myself nor in the Internet. I had to hack somewhat and after the view renders I do the following trick:

if ($("#LimitMax").data("kendoNumericTextBox").value() === null) {
    var rawValue = $("#LimitMax").attr("value");
    if (rawValue) {
        rawValue = rawValue.replace(",", ".");
    }
    if ($.isNumeric(rawValue)) {
        $("#LimitMax").data("kendoNumericTextBox").value(rawValue);
    } 
}
vanpersil
  • 764
  • 1
  • 8
  • 26