I am applying custom paging and sorting in the kendo grid. For one of my column I am getting a numeric text box. When I insert the value in numeric text box it is integer, but as the focus is removed from the filter numeric text box it converts into decimal. For eg: if I entered 32, it remains 32,but as the focus is removed the value becomes 32.00. But I want that value to remains 32.
So any one can please help me out with the solution.
On Kendo NumericTextBox, Format is used to format the content of the input when it's not focused. You have tu use Decimals du format the input when it's focused.
New to Kendo UI for jQuery ? Download free 30-day trial The purpose of number formatting is to convert a Number object to a human readable string using the culture-specific settings. The kendo.format and kendo.toString methods support standard and custom numeric formats.
"n" —Renders a number. kendo.culture ("en-US"); kendo.toString (1234.567, "n"); //1,234.57 kendo.toString (10.12, "n5"); //10.12000 kendo.toString (10.12, "n0"); //10
A custom numeric format string is any string which is not a standard numeric format. The following specifiers are supported by Kendo UI: "0" —The zero placeholder replaces the zero with the corresponding digit if such is present.
You can set like below
columns.Bound(x => x.Property).Filterable(x => x.UI("NumericFilter"));
<script type="text/javascript">
function NumericFilter(control) {
$(control).kendoNumericTextBox({ "format": "n0", "decimals": 0 });
}
</script>
Or use extension method
columns.NumericColumn(x => x.Property);
public static GridBoundColumnBuilder<TModel> NumericColumn<TModel, TValue>(this GridColumnFactory<TModel> Column, Expression<Func<TModel, TValue>> Expression) where TModel : class
{
return Column.Bound(Expression).Filterable(x => x.UI("NumericFilter"));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With