Extjs从新窗口引用父窗口
Extjs refer to parent window from new window
使用Extjs 5.0.1我有一个带有按钮的Ext.toolbar.Toolbar
。当我点击按钮时,会打开一个新窗口,里面有一个表单。在表单内,我需要参考工具栏,但使用form.up('toolbar')
不工作,它返回undefined
。这似乎是因为新窗口没有与工具栏绑定。我不想使用getCmp
,因为我没有使用id
属性。
你知道吗?
您可以使用Ext.ComponentQuery.query
来查找工具栏
使用xtype toolbar
,它将返回一个对象数组。
Ext.ComponentQuery.query('toolbar')[0];
如果你有多个工具栏,你可以给工具栏配置一个唯一的itemId,如itemId:'buttonToolbar'
。
Ext.ComponentQuery.query('#buttonToolbar')[0];
同样,你给配置工具栏一个唯一的名字,如name:'buttonToolbar'
。
Ext.ComponentQuery.query('toolbar[name=buttonToolbar]')[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.
}
相关文章:
- '文档'在子窗口中意外地引用了父窗口
- 为什么当我尝试将函数绑定到自身时,“this”对象仍然引用窗口
- 为什么根据括号的位置来引用窗口或对象?并返回undefined
- 如何在启动之前引用javascript窗口元素
- 为流星重新包装砌体会产生错误“引用错误:窗口未定义”
- 我应该使用 self 还是窗口来引用全局范围
- Ace 编辑器:未捕获的引用错误:窗口未定义
- 重定义对最顶层窗口的引用 (window.top)
- 是否可以在窗口属性上捕获未定义的引用
- 流星.js:引用错误:窗口未定义
- 无法获取未定义或空引用的属性“内容窗口”
- 如何关闭我的弹出窗口并保持在引用页面上的同一位置
- HTML5 postMessage没有窗口引用
- 如何在cookie中存储窗口引用
- 在GWT中使用第三方javascript库(带窗口引用)
- 如何将标签附加到窗口引用
- Extjs从新窗口引用父窗口
- 从具有目标"_blank"的窗体中获取窗口引用
- 在窗口引用上使用JQuery
- 将表单提交到新窗口>显示pdf>父窗口将丢失子窗口引用