简体   繁体   English

如何使用JavaScript并在Kendo UI模板中打印结果?

[英]How do I use JavaScript and print the result in a Kendo UI template?

For example,I use the these codes and it works well and the tooltip show the decimal number like "2.152". 例如,我使用这些代码,它运行良好,工具提示显示十进制数字,如“2.152”。

  tooltip: {
    visible: true,
    template: "<table style='color:red'><tr><td> #= value #</td></tr></table>"
   }

Now I want to use Math.round() function for the value of the tooltip,I use like these,but it do not work.It just show the "Math.round(2.152)" string,but I just want show "2". 现在我想使用Math.round()函数作为工具提示的值,我使用这些,但它不起作用。它只显示“Math.round(2.152)”字符串,但我只想显示“2 ”。

  tooltip: {
    visible: true,
    template: "<table style='color:red'><tr><td>Math.round(#=value#)</td></tr></table>"
   }

If you want to evaluate JS code and print the result, you need to surround the full expression with the delimiters: 如果要评估JS代码并打印结果,则需要使用分隔符包围完整表达式:

#= Math.round(value) #

Everything outside of that is simply treated as a string. 除此之外的所有内容都被视为字符串。

According to the document here ,if you use javascript,you shuld use #..# ,try the code again. 根据这里的文档,如果你使用javascript,你可以使用#..# ,再次尝试代码。

 tooltip: {
visible: true,
template: "<table style='color:red'><tr><td># Math.round(#=value#) #</td></tr></table>"

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM