简体   繁体   English

如何从Kendo网格中的ClientTemplate调用javascript方法?

[英]How to call javascript method from ClientTemplate in Kendo grid?

Is it possible to put in the ClientTemplate of Kendo grid a javascript statement? 是否可以在Kendo网格的ClientTemplate中添加一个javascript语句? I would like to calculate some data on the client and then to put the result in the row. 我想在客户端上计算一些数据,然后将结果放在行中。

I tried this: 我试过这个:

 columns.Bound("ExecutionStartDateTime").Title("SummaryLine").Width("20%").ClientTemplate("<script> scheduleForm.generateSummary(#= ExecutionStartDateTime #, 2); </script>");

However, it gave no effect. 但是,它没有任何效果。

You can, with template literal syntax: 您可以使用模板文字语法:

<script>
    function someFuntion(date) {
        var result = "";
        // Do whatever you need here (make ajax call etc..) and return result as html string
        return result;
    }
</script>

And bound your column as: 并将您的列绑定为:

columns.Bound("ExecutionStartDateTime").Title("SummaryLine").Width("20%")
    .ClientTemplate("#=someFuntion(ExecutionStartDateTime)#");   
// you can even pass 'data' implicit template parameter and extract ExecutionStartDateTime from there

You can even write inline javascript simply using # if(...){# ... #}# syntax. 您甚至可以使用#if(...){#...#}#syntax编写内联javascript。 This faq will help you. 这个常见问题将帮助您。

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

相关问题 如何获得Kendo Grid ClientTemplate价值到Javascript - How To Get Kendo Grid ClientTemplate Value To Javascript Kendo mvc Grid ClientTemplate javascript 功能不起作用 - Kendo mvc Grid ClientTemplate javascript function not working 如何从Kendo网格中包含按钮的列中向ClientTemplate发送值? - How can I send a value from a column in a Kendo Grid containing a button to a ClientTemplate? 如何在Kendo UI Grid ClientTemplate中创建条件按钮? - How to Make a Conditional Button in Kendo UI Grid ClientTemplate? ASP.NET MVC Kendo Grid 如何从 javascript 调用 controller 方法 - ASP.NET MVC Kendo Grid how to call controller method from javascript 无法从Kendo UI网格调用JavaScript - Can not call javascript from kendo ui grid Kendo UI Grid 在 ClientTemplate 中获取行 ID - Kendo UI Grid get Row Id in ClientTemplate 如何使用javascript setinterval方法定期刷新剑道网格 - How to refresh kendo grid periodically with javascript setinterval method 在按钮上单击后,如何使用javascript发出请求并使用ajax MVC Kendo UI网格调用读取方法 - Upon button click how to make request using javascript and call read method by using ajax MVC Kendo UI grid Kendo Grid自定义按钮调用Javascript函数 - Kendo Grid Custom Button To Call Javascript Function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM