NumericTextBox with HTML configuration decimals="0"

13 posts, 0 answers
  1. Siddhartha
    Siddhartha avatar
    7 posts
    Member since:
    Apr 2012

    Posted 26 Apr 2012 Link to this post

    Hi all,
    Problem reproduced at http://jsfiddle.net/nA95j/7/

    It seems that specifying decimals="0" option in the HTML initialization of numeric text box does not work. The same option when given as a constructor option does work.

    It is mentioned in the Release Notes for Kendo UI version 2012.1.322 that this is fixed (http://www.kendoui.com/web/whats-new/release-notes/q1-2012-version-2012-1-322.aspx) but I see it is happening in case of HTML based initialization for a numeric text box.

    I am using MVVM binding so I cannot declare the numeric text box and its arguments separately. Any suggestions or workarounds?

    Thanks.
  2. Ryan
    Ryan avatar
    4 posts
    Member since:
    Jan 2012

    Posted 26 Apr 2012 Link to this post

    change the code to:

    $("#currency").kendoNumericTextBox({
        decimals0,
        format'#'
    }); 

    the format string will set the control's display output...configuring the incrementer is an art form, mixing the correct settings for decimals, format, and step value :(
  3. Kendo UI is VS 2017 Ready
  4. Siddhartha
    Siddhartha avatar
    7 posts
    Member since:
    Apr 2012

    Posted 26 Apr 2012 Link to this post

    Thanks for the reply, Ryan, but like I said, I am initializing the numeric text box from HTML (bound to an MVVM), and I cannot use the javascript declaration style to specify the decimals and format parameters.
  5. Dimo
    Admin
    Dimo avatar
    8332 posts

    Posted 27 Apr 2012 Link to this post

    Hello Siddhartha,

    Please review the updated fiddle to see the correct way to configure the textbox.

    All the best,
    Dimo
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. Siddhartha
    Siddhartha avatar
    7 posts
    Member since:
    Apr 2012

    Posted 27 Apr 2012 Link to this post

    Thanks Dimo! This works fine. Appreciate the time you guys give to answering the queries.

    Did I miss something or is the documentation in need for an update on this issue?

    Thanks,
    Siddhartha
  7. Dimo
    Admin
    Dimo avatar
    8332 posts

    Posted 27 Apr 2012 Link to this post

    Hello Siddhartha,

    Declarative widget initialization is shown at

    http://demos.kendoui.com/web/mvvm/widgets.html

    MVVM bindings work with data attributes, which start with data-, as shown at

    http://www.kendoui.com/documentation/framework/mvvm/bindings/attr.aspx

    This is because custom attributes that do not start with data- are not valid HTML markup. For example, decimals HTML attribute does not exist.

    All the best,
    Dimo
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  8. Siddhartha
    Siddhartha avatar
    7 posts
    Member since:
    Apr 2012

    Posted 27 Apr 2012 Link to this post

    Thanks, guessed about the HTML compliance of min max etc. after a little while. 

    About the error, I was actually referring to the line first line of example on http://www.kendoui.com/documentation/ui-widgets/numerictextbox/configuration.aspx

    It talks about using "decimals" instead of "data-decimals" for HTML: 
    // specify in the HTML
    <input id="numeric" value="10" type="number" min="0" max="1" step=".1" decimals="1"/>
    <br />
  9. Siddhartha
    Siddhartha avatar
    7 posts
    Member since:
    Apr 2012

    Posted 27 Apr 2012 Link to this post

    Thanks, guessed about the HTML compliance of min max etc. after a little while. 

    About the error, I was actually referring to the line first line of example on http://www.kendoui.com/documentation/ui-widgets/numerictextbox/configuration.aspx

    It talks about using "decimals" instead of "data-decimals" for HTML: 
    // specify in the HTML
    &lt;input id="numeric" value="10" type="number" min="0" max="1" step=".1" decimals="1"/&gt;
    <br />
  10. Dimo
    Admin
    Dimo avatar
    8332 posts

    Posted 27 Apr 2012 Link to this post

    This must be a copy-paste error, we'll fix that, sorry about the confusion.

    Greetings,
    Dimo
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  11. Bill
    Bill avatar
    13 posts
    Member since:
    Jul 2012

    Posted 13 Aug 2012 Link to this post

    The declarative configuration shown in http://jsfiddle.net/dimodi/nA95j/10/  (data-decimals="0")  does not work to suppress decimals for stationary display of a number.  Rather it seems to affect the display when increasing or decreasing values.   Curiously, data-format = "d" does suppress decimals in the display, as well as in the increase and decrease.
  12. Dimo
    Admin
    Dimo avatar
    8332 posts

    Posted 16 Aug 2012 Link to this post

    Hello Bill,

    Decimals is related to the input textbox only. Format should be used to control the formatted value. Please refer to the updated example:

    http://jsfiddle.net/dimodi/nA95j/85/

    Greetings,
    Dimo
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  13. Alton
    Alton avatar
    1 posts
    Member since:
    Jan 2014

    Posted 25 Sep 2014 Link to this post

    @Dimo, didnt know if you noticed, but when I look at the JSFiddle it shows 2 decmials during display.  If I click to edit, it looses the decimals, but they are always there unless I am editing.
  14. Dimo
    Admin
    Dimo avatar
    8332 posts

    Posted 29 Sep 2014 Link to this post

    Hello Alton,

    - decimals is applicable when the widget is focused
    - format is applicable when the widget is not focused

    Regards,
    Dimo
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready