Numeric Formats?

23 posts, 0 answers
  1. Luis Escobedo
    Luis Escobedo avatar
    5 posts
    Member since:
    Aug 2009

    Posted 13 Dec 2011 Link to this post

    Is there any documentation on how the numeric formats work exactly? I just want a simple non-decimal percentage text box(1-100%, whole numbers, no decimals), but I can't quite seem to figure out the right format. Here's my code:

    $(".txtPct").kendoNumericTextBox({
                    format: "p0",
                    min: 0,
                    max: 100,
                    step: 1
                });

    Any help would be appreciated. Also, any plans to update the documentation? There seems to be a lot of stuff that needs to be "discovered" by the developer at this point. Thanks!
  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 13 Dec 2011 Link to this post

    Hello Luis Escobedo,

     
    You can use the decimals option when initialize the widget. Check the Configuration/decimals section.

    Regards,
    Georgi Krustev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
  4. Luis Escobedo
    Luis Escobedo avatar
    5 posts
    Member since:
    Aug 2009

    Posted 13 Dec 2011 Link to this post

    hmmm, nope, decimals option doesn't really do anything. So if I change the config to this:

      $(".txtPct").kendoNumericTextBox({
                    format: "p0",
                    min: 0,
                    max: 100,
                    step:1,
                    value:25,
                    decimals:0
                });

    It will give me "2,500%" in the textbox?? So 100x what I want. Can it only use step decimals in percentages? I also tried other formats like "n%", "0%", but none of those worked,
  5. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 14 Dec 2011 Link to this post

    Hello Luis,

     
    By design when "p" or "%" is used in the format, the value is multiplied by 100. Currently excaping the "%" symbol or using literals in the format is not supported. It is in our ToDo list, but I will not be able to give a specific time frame for the implementation.  

    Regards,
    Georgi Krustev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. zenit1
    zenit1 avatar
    12 posts
    Member since:
    Jun 2008

    Posted 21 Dec 2011 Link to this post

    Hi , Georgi

    Where I can find all allowed values for format parameter?

    Thanks

    Serge
  7. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 22 Dec 2011 Link to this post

    Hi,

    Currently, the supported formats are not clearly documented. We are working on this and soon we will update the docs for the globalization. We have used these specifications for implementing the number formatting -
    http://msdn.microsoft.com/en-us/library/dwhawy9k(v=vs.71).aspx
    http://msdn.microsoft.com/en-us/library/0c899ak8.aspx

    Kind regards,
    Georgi Krustev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  8. Ned
    Ned avatar
    6 posts
    Member since:
    Dec 2011

    Posted 22 Aug 2012 Link to this post

    I know this is a really old thread, but I'm having the same problem.  Was escaping the "%" symbol ever supported?

    Thanks,
    Ned
  9. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 23 Aug 2012 Link to this post

    Hello Ned,

    You need to make the "%" symbol a literal in order to avoid default behavior. Check this jsBin demo.

    Kind regards,
    Georgi Krustev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  10. Ned
    Ned avatar
    6 posts
    Member since:
    Dec 2011

    Posted 23 Aug 2012 Link to this post

    In the jsBin demo, the percent sign is surrounded in single quotes.  I had already tried that.  That's not going to work for me...  So there's no way to escape it and not have the escape characters show up in the formatted result?

    Thanks,
    Ned
  11. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 23 Aug 2012 Link to this post

    Hello Ned, 

    Currently escaping the percent sign is not supported. I will add your feature request to our internal system for further investigation and consideration. If other users need this functionality we will schedule it for development.
     

    Kind regards,
    Georgi Krustev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  12. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 23 Aug 2012 Link to this post

    Hello Ned,

     
    After further investigation, we decided to implement the required functionality. It is available in the last internal build (2012.2.823).

    Kind regards,
    Georgi Krustev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  13. Jonathan
    Jonathan avatar
    37 posts
    Member since:
    Jul 2012

    Posted 24 Aug 2012 Link to this post

    Now that the newest release is out, could you explain how to do this? Thanks.
  14. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 27 Aug 2012 Link to this post

    Hello Jonathan,

     
    Yuo can escape the "%" sign like this:

    "# \\%"


    Regards,

    Georgi Krustev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  15. Jonathan
    Jonathan avatar
    37 posts
    Member since:
    Jul 2012

    Posted 27 Aug 2012 Link to this post

    Thanks! Works great
  16. Michael
    Michael avatar
    2 posts
    Member since:
    Apr 2012

    Posted 28 Aug 2012 Link to this post

    Any updates on when this will be documented?
    I am trying to make it just display an int, but I always get 1.00

    Tried  format: 'g', and  format: 'G', but no luck there
  17. Ned
    Ned avatar
    6 posts
    Member since:
    Dec 2011

    Posted 28 Aug 2012 Link to this post

    Try "n0".  That's lower-case N and the number zero (for the number of decimal places).
  18. Michael
    Michael avatar
    2 posts
    Member since:
    Apr 2012

    Posted 28 Aug 2012 Link to this post

    That works, thank you!
  19. Sergiu
    Sergiu avatar
    6 posts
    Member since:
    Jan 2012

    Posted 02 Nov 2012 Link to this post

    '# \\%' doesn't work for me.
    I just want to display the percent sign and i don't want the value multiplied by 100. Any suggestions? Thanks.
  20. Jacques
    Jacques avatar
    135 posts
    Member since:
    Jun 2007

    Posted 29 Nov 2013 Link to this post

    Aren't these supposed to be premium forums? This question was asked in 2012? 
    And why is the documentation still not complete? 

    I'm having the same stupid issue. I'm not sure why anyone would want a user to enter a percentage as fractions? 

    I'm doing this with a kendo Grid and MVVM binding. The grid's row template looks as follows (ignore zzz - just hiding business specific stuff): 

    <script id="row-template" type="text/x-kendo-template">
            <tr>
                <td></td>
                <td data-bind="text: zzz">
                </td>
                <td data-bind="text: zzz">
                </td>
                <td>
                    <input data-role="dropdownlist" data-text-field="zzz" data-value-field="zzz" data-bind="{source: zzz, events: {change: zzz, dataBound: zzz}}" data-value-primitive="true" />
                </td>
                <td class="text-right">
                    <input class="editable" data-role="numerictextbox" data-format="P0 data-bind="{value: zzz}" data-min="0" data-max="100" />%
                </td>
                <td class="text-right">
                    #: zzz #
                </td>
                <td class="text-right">
                    #: zzz #
                </td>
                <td class="text-right">
                    #: zzz #
                </td>
                <td class="text-right">
                    #: zzz #
                </td>
            </tr>
        </script>
    The result is that the it uses fractions and users automatically put in 10% which multiples by 100, so no go there. 

    I replaced the format with "# \\%"
    The result is an exception: "Invalid template" 

    If I replace "# \\%" with "# %' it still throws the same exception. 
    Escaping the # as in "\\# \\%" works. 

    Hope this helps someone. 
  21. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 04 Dec 2013 Link to this post

    Hello Jacques,

    The Premium forums were introduced after the last post in this forum thread. Before that the forums were supported by the community itself and we did not guarantee any response, although, we tried to answer to all threads.

    The percent format "p" by design multiplies the number by 100. I will suggest you check our documentation about the supported formats. Also you can examine the MSDN numeric format documentation, which is very explanatory.

    The Kendo Templates uses "#" as part of its binding expression and if you have "#" symbol you will need to escape it. As you pointed in this case the correct format is "\\# \\%".

    Regards,
    Georgi Krustev
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  22. Masaab
    Masaab avatar
    15 posts
    Member since:
    Nov 2013

    Posted 26 Nov 2014 in reply to Luis Escobedo Link to this post

    you can use
     format: "#"

    @(Html.Kendo().NumericTextBoxFor(m => m.MaximumFileCount)
                                                              .Min(0)
                                                              .Max(100)
                                                              .Decimals(0)
                                                              .Format("#"))
  23. Piyush Bhatt
    Piyush Bhatt avatar
    17 posts
    Member since:
    Oct 2014

    Posted 27 Feb 2015 Link to this post

    By the way, this does not work as in GRID column.
  24. Piyush Bhatt
    Piyush Bhatt avatar
    17 posts
    Member since:
    Oct 2014

    Posted 04 Mar 2015 in reply to Piyush Bhatt Link to this post

    Found the answer. For GRID column use field template like this - 

    template: '#=kendo.format("{0:p}", value/ 100)#'

    Replace value with field/column name.
Back to Top
Kendo UI is VS 2017 Ready