我目前有一个带有按钮的网格,单击该按钮即可对网格中的记录进行操作。目前我使用 button.up('selector');
来获取网格,但感觉有点hacky。我认为也许通过将点击事件选择器更改为grid [action=buttonAction]
而不仅仅是[action=buttonAction]
可能会给我网格的上下文,但事实并非如此。有没有比 button.up
更简洁的方法来引用网格?
var dockedItems = new Ext.toolbar.Toolbar({
items: {
text: 'Do a thing',
action: 'actionForTheThing'
}
});
Ext.grid.Panel({
store: this.store,
dockedItems: dockedItems,
});
然后在 Ext.app.Controller
Controller 中我定义一个处理程序
this.control({
'[action=actionForTheThing]': {
click: this.handleTheThing
},
handleTheThing: function(button, click){
//Here I have the button, but I want to get to the grid that has the button
// Right now I can do button.up(''), but I want more of a strict relationship
//like button.getParent(); or something.
};
最佳答案
不,没有。
按钮的单击事件始终以按钮作为第一个参数来触发,要更改这一点,您必须在按钮上创建一个重写,重写 fireHandler
方法,其中 click
事件被触发:
me.fireEvent('click', me, e)
http://docs.sencha.com/extjs/6.2.1/classic/src/Button.js.html#line1643
关于javascript - Extjs 5 通过停靠按钮的单击事件引用网格而不使用 .up?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46059258/