1

I am trying to delete/add rows to a grid.

Let's say for delete, I have created an actioncolumn like this:

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

And the handler:

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

But for some reason, I get the error:

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

I copied the code from here, but it doesn't seem to work for me.

grid

4

2 回答 2

2

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

于 2013-10-03T15:50:24.347 回答
2

该错误是说您的 this 指向您的“MyViewport”而不是您的网格或其商店

于 2013-10-03T17:39:10.303 回答