jqueryasp.netasp.net-mvckendo-uikendonumerictextbox

Problems with decimal value in kendoNumericTextBox asp.net mvc


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?


Solution

  • 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);
        } 
    }