日期:2014-05-16 浏览次数:20425 次
Ext.onReady(function(){Ext.create('Ext.panel.Panel', {
width: 1024,
height: 800,
layout: 'border',
id:'mainPanel',
items: [{
region:'north',
xtype:'form',
height:145,
layout: 'absolute',
margins: '0 3 3 3' ,
items:[{ x: 0, y: 0, xtype: 'button', text: '添加panel' , listeners: {
click: {fn: function(){aa();}}
}}]
},{
region: 'center',
xtype: 'panel',
layout: 'border',
margins: '0 3 3 3' ,
id : 'centerPanel'
},{
region: 'south',
xtype: 'panel',
height: 100,
margins: '0 3 3 3'
}],
renderTo: Ext.get('main-div')
});
function aa(){
var p = Ext.create('Ext.panel.Panel', {
width: 200,
height:200,
html: '<p>Hello World!</p>'
});
p.render(Ext.get('centerPanel'),'center');
Ext.getCmp('centerPanel').doLayout();
Ext.getCmp('mainPanel').doLayout();
alert('aa end');
}});
function aa() {
var p = Ext.create('Ext.panel.Panel', {
width: 200,
height: 200,
html: '<p>Hello World!</p>'
});
p.render(Ext.get('centerPanel').down('div'), 'center');//panel里面还会放置一个div用于显示内容,你要render到那个div里面,要不显示在父容器由于设置了overflow:hidden导致你这个新panel无法看到
}