typescript从字符串调用kendo ui方法

typescript kendo-ui call method from string

本文关键字:ui 方法 kendo 调用 字符串 typescript      更新时间:2023-09-26

我在kendo ui(html)的网格中使用带有类型脚本的dropdrownlist

问题是我必须调用字符串中的函数

export class ClassName extends BaseController {
    public configureGrid()
        {
           .... //other codes
              columnView.template =  "#= methodToBeCalled(columnValue) #";
        }
    }
    public methodToBeCalled(...params:any[])
            {
                return "something";
            }

我应该如何从字符串中定义的typescript中调用"methodToBeCalled"。我试过这些组合,没有一个能起的作用

      columnView.template =  "#= methodToBeCalled(columnValue) #";
      columnView.template =  "#= this.methodToBeCalled(columnValue) #";
      columnView.template =  "#= _this.methodToBeCalled(columnValue) #";
      columnView.template =  "#= ClassName.methodToBeCalled(columnValue) #";

尝试手动编译模板,然后使用Function.prototype.bind:

columnView.template = kendo.template("#=methodToBeCalled(columnValue)#").bind(this);