【问题标题】:Dropdown list editor in Aurelia Kendo GridAurelia Kendo Grid 中的下拉列表编辑器
【发布时间】:2016-06-29 15:21:35
【问题描述】:

这是我从here得到的下拉代码:

myDropDownEditor(container, options) {
            //var fieldName="";

                $('<input required data-text-field=\"myType\" data-value-field="id" data-bind="value:name"/>')
                    .appendTo(container)
                    .kendoDropDownList({
                        autoBind: false,
                        dataSource: {
                          data: this.myList
                        }
                    });
        }

在运行时,当我单击网格上的编辑按钮时,出现以下错误:

my-type.ts:138 Uncaught TypeError: Cannot read property 'myList' of undefined

有什么想法吗?

【问题讨论】:

  • 你确定你在 this.myList 中有数据并且它不是像错误提示的那样未定义吗?
  • @calinaadi 是的,我确定。
  • 我会说那个上下文中的“this”是指尚未创建且未定义的数据源。
  • 尝试将myDropDownEditor(container, options) { ... }更改为myDropDownEditor = (container, options) =&gt; { ... }

标签: kendo-ui kendo-grid aurelia


【解决方案1】:

你需要这样做,

dropdownEditor(container: any, options: any) {
    const dropDownData = [
      { name: 'One', value: 'ValueOne' },
      { name: 'Two' value: 'ValueTwo' },
      { name: 'Three', value: 'ValueThree' }
    ];
    $('<input required data-bind="value:' + options.field + '"/>')
      .appendTo(container)
      .kendoDropDownList({
        dataTextField: 'name',
        dataValueField: 'value',
        dataSource: dropDownData,
        optionLabel: 'Please select'
      });
  }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多