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

Adding a % sign to a percentage in a NumericTextBox

1 Answer 2099 Views
NumericTextBox
This is a migrated thread and some comments may be shown as answers.
M
Top achievements
Rank 1
M asked on 02 Jan 2013, 07:42 PM

Trying to add a % sign to a number in a Kendo NumericTextBox. You suggest escaping the % sign as such:

$("#numeric").kendoNumericTextBox({
    format: "# \%"
});

but when I give it a value of 3, it still gives me 300%!

From your documentation:

"%" - percentage placeholder Multiplies a number by 100 and inserts a localized percentage symbol in the result string. Note: '%' symbol is interpreted as a format specifier in the format string. If you need to prevent this, you will need to precede the '%' symbol with a backslash -'kendo.toString(12, "# \%")' -> 12 % (en-us).

1 Answer, 1 is accepted

Sort by
0
Accepted
Alexander Valchev
Telerik team
answered on 03 Jan 2013, 01:47 PM
Hello,

There is a mistake in the documentation. To escape the % symbol you should use double back slash (\\).
$("#numeric1").kendoNumericTextBox({
    format: "# \\%"
});
 
kendo.format("{0:# \\%}", 12); //12 %
kendo.toString(12, "# \\%"); //12 %

Here is a runnable example: http://jsbin.com/igexug/3/edit

The help article will be updated soon. As a small sign of our appreciation for bringing this to our attention I updated your Telerik points.

Kind regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Lee
Top achievements
Rank 2
Bronze
Bronze
Bronze
commented on 21 Aug 2023, 01:59 PM | edited

The example link doesn't seem to work anymore. Here is an updated dojo I made: Kendo Percentage Text Box Dojo
Tags
NumericTextBox
Asked by
M
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or