使用Extjs 5.0.1我有一个带有按钮的#rating-box {
width: 100%;
margin: 20px 0 20px 0;
}
#rating-box .rating {
width: 35px;
height: 35px;
background-color: #7a7a7a;
margin: 0 auto;
}
。当我点击按钮时,会打开一个新窗口,里面有一个表格。在表单中我需要引用工具栏,但使用Ext.toolbar.Toolbar
不起作用,它返回form.up('toolbar')
。看起来因为新窗口没有与工具栏绑定。我不想使用undefined
因为我没有使用getCmp
属性。
你有什么想法吗?
答案 0 :(得分:2)
您可以使用Ext.ComponentQuery.query
查找工具栏。
使用xtype toolbar
,它将返回一个对象数组。
Ext.ComponentQuery.query('toolbar')[0];
如果您有多个工具栏,则可以在配置工具栏中为itemId:'buttonToolbar'
提供一个唯一的itemId。
Ext.ComponentQuery.query('#buttonToolbar')[0];
同样,您可以在配置中为name:'buttonToolbar'
添加工具栏的唯一名称。
Ext.ComponentQuery.query('toolbar[name=buttonToolbar]')[0];
答案 1 :(得分:0)
onBtnABCClick:function(btn) {
Ext.create('MyApp.view.NewWindow',{
myParentToolbar: btn.up('toolbar') // <- here you give your new window a config item
});
}
onWindowAfterRender:function(component) {
// here you can access the new config item:
component.config.myParentToolbar.down('button[itemId=ABC]').setDisabled(true);
// in ExtJS 4, it was "component.myParentToolbar", in ST2 "component.config.myParentToolbar".
// Unsure about ExtJS 5, please test both possibilities.
}