Search code examples
kendo-uiangular-kendo

I need to 1/10 and 1/100 part of percent in kendo ui numeric text box


I need to 1/10 and 1/100 part of percent, but kendo ui numeric text box allows enter a whole percent. I try to do something like thins:

$("#percent").kendoNumericTextBox({
  format: "##.0000 %"
});

but it doesn't work.

Any ideas?


Solution

  • Depending on how you want to manage the value assigned there are two possible solutions.

    Case 1: If you want that value 12.3456 gets displayed as 12.3456%, you should do:

    $("#percent").kendoNumericTextBox({
        format: "##.0000 \\%",
        decimals: 4,
        value: 12.3456
    });
    

    Case 2: If you want that value 12.3456 gets displayed as 1234.5600%, you should do:

    $("#percent").kendoNumericTextBox({
        format: "p4",
        decimals: 4,
        value: 12.3456
    });
    

    Case 3: If you want that value 12.3456 gets displayed as 1234.56%, you should do:

    $("#percent").kendoNumericTextBox({
        format: "p2",
        decimals: 4,
        value: 12.3456
    });
    

    See it in action here: http://jsfiddle.net/OnaBai/4ab9Z/