无法从kendotreelist中的kendo模板调用typescript中的函数

Not able to call function in typescript from kendo template in kendotreelist

本文关键字:typescript 调用 函数 kendotreelist 中的 kendo      更新时间:2023-09-26

Kendo树列出了类A中的代码(typescript文件(:我已经调用了Kendo模板中的一个函数。

export class A{                        
            drillDownDataSource: any;        
            constructor() {               
                    this.GetStatutoryIncomeGridViewData();
            }    
            GetStatutoryIncomeGridViewData() {        
                $.ajax({
                    type: 'POST',
                    url: 'Controller/Action/',
                    data: stfilterData,
                    success: function (data) {
                   $("#grid").kendoTreeList({
                    dataSource: data,                                       
                    columns: [
                 { field: "Transaction1",
template:kendo.template("#=FormatNumberToEn(Transaction1)#").bind(this) },
                                        }                    
                });
            });
      public FormatNumberToEn(value) { }
    }
    } 

获取错误function FormatNumberToEn is undefined

如果你想在KendoUI模板中使用函数,你必须在全局(JavaScript-(范围中定义它们。(参考(

只需从类A中提取FormatNumberToEn函数。

export class A { 
    /* class definition */ 
}
function FormatNumberToEn(value) { /* function logic */ }

或者,将函数定义为static并在模板内调用A.FormatNumberToEn()也可以。(现在无法测试,因为我在移动设备上。(