Reputation: 34109
I am using kendo.toString()
method to format string as documented here
So for example
kendo.culture("en-US");
kendo.toString(5000, "n")
returns 5,000
However if i pass string parameter then it does not work
kendo.culture("en-US");
kendo.toString("5000", "n")
returns 5000
Upvotes: 0
Views: 5542
Reputation: 16814
To format a number with kendo.toString()
you should pass a number and not a string
You can simply parse it:
var val = parseFloat($(this).val());
val = kendo.toString(val, "n")
See updated JSFiddle
See kendo.toString()
logic
From kendo.all.js:
var toString = function (value, fmt, culture) {
if (fmt) {
if (objectToString.call(value) === '[object Date]') {
return formatDate(value, fmt, culture);
} else if (typeof value === NUMBER) {
return formatNumber(value, fmt, culture);
}
}
return value !== undefined ? value : '';
};
}
In case value
is a string, toString()
will echo it back
Upvotes: 2
Reputation: 6096
I noticed that doing the following seemed to work, so I guess that particular method does not support string inputs.
kendo.culture("en-US");
$("#testnumber").text(kendo.toString(5000,"n"))
$("#myinput").change(function(){
var val = $(this).val();
val = kendo.toString(parseFloat(val), "n")
$(this).val(val);
})
Upvotes: 1