Numeric Formats?

4 Answers 3277 Views
NumericTextBox
Luis Escobedo
Top achievements
Rank 1
Luis Escobedo asked on 13 Dec 2011, 07:38 AM
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!

4 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 13 Dec 2011, 01:16 PM
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!
Luis Escobedo
Top achievements
Rank 1
commented on 13 Dec 2011, 06:07 PM

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,
Georgi Krustev
Telerik team
commented on 14 Dec 2011, 11:35 AM

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!
zenit1
Top achievements
Rank 2
commented on 21 Dec 2011, 11:30 PM

Hi , Georgi

Where I can find all allowed values for format parameter?

Thanks

Serge
Georgi Krustev
Telerik team
commented on 22 Dec 2011, 10:47 AM

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!
Ned
Top achievements
Rank 1
commented on 22 Aug 2012, 04:31 PM

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

Thanks,
Ned
Georgi Krustev
Telerik team
commented on 23 Aug 2012, 08:27 AM

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!
Ned
Top achievements
Rank 1
commented on 23 Aug 2012, 12:42 PM

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
Georgi Krustev
Telerik team
commented on 23 Aug 2012, 01:07 PM

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!
0
Georgi Krustev
Telerik team
answered on 23 Aug 2012, 02:23 PM
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!
Jonathan
Top achievements
Rank 1
commented on 24 Aug 2012, 06:38 PM

Now that the newest release is out, could you explain how to do this? Thanks.
Georgi Krustev
Telerik team
commented on 27 Aug 2012, 09:48 AM

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!
Jonathan
Top achievements
Rank 1
commented on 27 Aug 2012, 02:25 PM

Thanks! Works great
Michael
Top achievements
Rank 1
commented on 28 Aug 2012, 06:45 PM

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
Ned
Top achievements
Rank 1
commented on 28 Aug 2012, 06:48 PM

Try "n0".  That's lower-case N and the number zero (for the number of decimal places).
Michael
Top achievements
Rank 1
commented on 28 Aug 2012, 07:59 PM

That works, thank you!
Sergiu
Top achievements
Rank 1
commented on 02 Nov 2012, 09:14 AM

'# \\%' 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.
Jacques
Top achievements
Rank 2
commented on 29 Nov 2013, 07:49 AM

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. 
Georgi Krustev
Telerik team
commented on 04 Dec 2013, 08:30 AM

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!
Piyush Bhatt
Top achievements
Rank 1
commented on 27 Feb 2015, 10:10 PM

By the way, this does not work as in GRID column.
0
Masaab
Top achievements
Rank 1
answered on 27 Nov 2014, 05:32 AM
you can use
 format: "#"

@(Html.Kendo().NumericTextBoxFor(m => m.MaximumFileCount)
                                                          .Min(0)
                                                          .Max(100)
                                                          .Decimals(0)
                                                          .Format("#"))
0
Piyush Bhatt
Top achievements
Rank 1
answered on 04 Mar 2015, 11:25 PM
Found the answer. For GRID column use field template like this - 

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

Replace value with field/column name.
Tags
NumericTextBox
Asked by
Luis Escobedo
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Masaab
Top achievements
Rank 1
Piyush Bhatt
Top achievements
Rank 1
Share this question
or