Kendo网格列号格式化

Avi*_*tor 6 templates number-formatting kendo-ui kendo-grid

如果绑定2个数据值,如何在kendo列中设置数字格式?在我的例子中,我必须将值与单位绑定,所以我需要一个用2位小数写的值.我的代码看起来像:

{
    field: "Quantity",
    title: "Value ",
    width: "70px",
    type: "number",
    format:"{0:n2}",
    template: "#:Quantity# #:Unit#",
    attributes:{style:"text-align:right;"}
},
Run Code Online (Sandbox Code Playgroud)

没有它绑定到单位它很好,但有单位我有一个问题.提前致谢

Ric*_*k S 14

这将格式化Quantity为显示为2位小数的数字

template: '#= kendo.toString(Quantity, "n2")#  #=Unit#'
Run Code Online (Sandbox Code Playgroud)

  • 我错过了一个#号。使用上面的方法再试一次。 (2认同)