Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the kendo numeric filter format

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.

like image 370
Anirudh Agarwal Avatar asked Feb 28 '13 06:02

Anirudh Agarwal


People also ask

What is the use of format on kendo numerictextbox?

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.

What's new to Kendo UI for jQuery?

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.

What does n mean in kendo tostring?

"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

What is a custom numeric format string?

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.


1 Answers

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"));

}
like image 186
Palanikumar Avatar answered Sep 28 '22 04:09

Palanikumar