Search code examples
kendo-uikendo-gridkendo-template

What is wrong with my kendo template


I need to display trailing .00 decimals if the column Value of the provided model doesn't have it already.

What I have tried out is:

template:AmountRepLookup == 1601 ? "# if(#'#=Value#'#.indexOf('.') == -1) ){# #= '$' + Value # #}else{# #= '$' + Value +'.00' # #}#" : "# if(#'#=Value#'#.indexOf('.') == -1) ){# #= Value + '%' # #}else{# #= Value +'.00%' # #}#"

Expected output:

$XX.00 or XX.00%


Solution

  • use this

    use {0:c2} for $ with 2 digit decimal
    use {0:p} for percentage values
    
    #= kendo.format('{0:c2}', value)# //dollar    
    #= kendo.format('{0:p}', value)# //Percentage
    

    You already have a Boolean conditions, just use formatting functions