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) { }
}
}
出现错误函数FormatNumberToEn未定义
最佳答案
如果您想在 KendoUI 模板中使用函数,您必须在全局 (JavaScript-) 范围中定义它们。 (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/