This is a migrated thread and some comments may be shown as answers.

Problem with TagHelper for integer numbers

3 Answers 208 Views
NumericTextBox
This is a migrated thread and some comments may be shown as answers.
Emmsa
Top achievements
Rank 2
Emmsa asked on 07 Apr 2017, 07:59 PM

Hello,

I want to set a NumericTexbox to work with integer numbers without decimals, but using taghelper didn't work.

This code block shows the number with 2 decimals:
<kendo-numerictextbox for="Id" spinners="false" decimals="0" format="#"/>

But if I use this code block, it works as expected:
@Html.Kendo().NumericTextBoxFor(model => model.Id).Format("#").Decimals(0).Spinners(false)

Thanks

3 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 12 Apr 2017, 02:27 PM
Hi,

In order to apply formatting to the NumericTextBox you should specify the DisplayFormat attribute for the field in the Model.

The code snippet below outlines the approach:

[DisplayFormat(DataFormatString = "{0:n0}" , ApplyFormatInEditMode =true)]
public int Id { get; set; }



Regards,
Viktor Tachev
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Christian Sandöy
Top achievements
Rank 2
answered on 08 Dec 2017, 09:18 AM
What DataFormatString should I use if I dont want thousand separator
0
Konstantin Dikov
Telerik team
answered on 13 Dec 2017, 07:46 AM
Hi Christian,

You could use the following custom format for displaying an integer value without group or decimal separators:
{0:#}

More information for the custom numeric formats could be found in the following MSDN article:

Best Regards,
Konstantin Dikov
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
NumericTextBox
Asked by
Emmsa
Top achievements
Rank 2
Answers by
Viktor Tachev
Telerik team
Christian Sandöy
Top achievements
Rank 2
Konstantin Dikov
Telerik team
Share this question
or