Problem with TagHelper for integer numbers

2 posts, 0 answers
  1. Emmsa
    Emmsa avatar
    63 posts
    Member since:
    Oct 2006

    Posted 07 Apr Link to this post

    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

  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1768 posts

    Posted 12 Apr Link to this post

    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.
Back to Top