How to call javascript method from ClientTemplate in Kendo grid?

前端 未结 1 1323
旧巷少年郎
旧巷少年郎 2020-12-17 20:23

Is it possible to put in the ClientTemplate of Kendo grid a javascript statement? I would like to calculate some data on the client and then to put the result in the row.

相关标签:
1条回答
  • 2020-12-17 21:04

    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. This faq will help you.

    0 讨论(0)
提交回复
热议问题