0
我目前有一个网格,上面有一个按钮,我可以点击网格上的记录。目前我使用button.up('selector');
来获取网格,但感觉有点冒险。我认为可能通过改变点击事件选择器为grid [action=buttonAction]
而不是仅仅[action=buttonAction]
可能会给我网格的上下文,但事实并非如此。有没有更清晰的方式来引用网格而不是button.up
?Extjs 5参考网格由停靠按钮的点击事件而不使用.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
控制器我定义了一个处理程序
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.
};
总有可能被设置为网格范围配置(假设你有一个变种可用的网格)http://docs.sencha.com/extjs/6.2.1/modern/ Ext.Button.html#CFG-范围 –