【问题标题】:Deleting and Adding rows to grid删除和添加行到网格
【发布时间】:2013-10-03 15:46:11
【问题描述】:

我正在尝试向网格中删除/添加行。

假设删除,我创建了一个这样的操作列:

{
     xtype: 'actioncolumn',
     width: 30,
     sortable: false,
     menuDisabled: true,
     items: [{
          icon: 'images/delete.png',
          scope: this,
          handler: this.onRemoveClick
     }]
}

还有处理程序:

onRemoveClick: function(grid, rowIndex){
    this.getStore().removeAt(rowIndex);
}

但由于某种原因,我得到了错误:

"Uncaught TypeError: Object [object Object] has no method 'getStore'"

我从here 复制了代码,但它似乎对我不起作用。

【问题讨论】:

    标签: extjs


    【解决方案1】:

    此时您使用this 的范围是错误的。您可以使用具有正确范围的变量来引用处理程序中的网格,或者您可以使用actioncolumnscope 配置选项。在此处查看文档:http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.grid.column.Action-cfg-scope

    【讨论】:

    【解决方案2】:

    那个错误是说你的 this 指向你的“MyViewport”而不是你的网格或其商店

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-02-12
      • 1970-01-01
      • 2015-07-24
      • 2013-07-25
      • 1970-01-01
      • 1970-01-01
      • 2012-01-14
      相关资源
      最近更新 更多