gpt4 book ai didi

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

转载 作者:搜寻专家 更新时间:2023-10-30 21:24:24 25 4
gpt4 key购买 nike

Kendo TreeList code in class A (typescript file): I have given call to a function from kendo template.

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-)Scope 中定义它们。 ( Reference )

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

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

或者将您的函数定义为 static 并在模板内调用 A.FormatNumberToEn() 也可能有效。 (我现在无法在移动设备上进行测试。)

关于javascript - 无法从kendotreelist中的kendo模板调用 typescript 中的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39384524/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com