我有一个边界布局,其中我必须展开和折叠东部区域以获得一些视图,屏幕一开始工作得很好,但当你点击浏览器的刷新按钮时,如果东部区域被折叠,那么你就会得到东部区域的折叠,根据我的理解,这不应该发生,因为每次刷新时都会从一开始执行extJS代码,因此在刷新后东部区域必须可见。
使东部区域在每次用户刷新时扩展我试着去下面的
Ext.getCmp('center_panel').add({
id: 'center_panel_container',
layout: 'border',
defaults: {
'border': true
},
items:[{
id : 'header_panel',
layout: 'fit',
region: 'north',
height: 30,
items: [tbar]
},{
id: 'master_panel',
layout: 'fit',
region: 'center',
width: '60%',
bodyStyle:{"background-color":"white"},
autoScroll: true,
items: [panelLeft,panelLeftSchd,panelLeftStartUp]
}, {
id: 'report_panel',
layout: 'fit',
region: 'east',
width : '40%',
split:true,
autoScroll: true,
items: [panelRight, panelRightStartUp]
}]
});
Ext.getCmp('report_panel').expand(true);
但我得到以下错误this.el为null或不是对象。
每当用户每次点击刷新时,如何使东部区域扩展
谢谢,
之所以会发生这种情况,是因为Ext.getCmp('report_panel')
在您尝试调用其展开方法时未被渲染。这是因为ExtJS在布局组件时有时会使用setTimeout
。最简单的解决方案是等待呈现事件并从该处理程序调用expand
{
id: 'report_panel',
layout: 'fit',
region: 'east',
width : '40%',
split:true,
autoScroll: true,
items: [panelRight, panelRightStartUp],
listeners: {
render: function(panel) {
panel.expand()
}
}
}
您也可以等待父容器的afterlayout
事件。
拆分器往往会记住自己的状态,因此在刷新时,拆分器会将自己设置到上一个会话中的位置,以便忘记自己的状态。请执行以下
{
id: 'report_panel',
layout: 'fit',
region: 'east',
width : '40%',
split:true,
**stateful : false,**
autoScroll: true,
items: [panelRight, panelRightStartUp]
}