PDA

View Full Version : Ext.layout.container.Border : css : height : 0px



betimonde
28 Feb 2012, 5:28 AM
Newer in extjs, i have an issue when trying to create a new mvc view.
the <div> are created but the style height = 0px;


<div id="panel-1036" class="x-panel x-box-item x-panel-default" style="margin-left: 0px; margin-bottom: 0px; margin-right: 0px; margin-top: 0px; width: 225px; height: 0px; left: 0px; top: 0px; " role="presentation" aria-labelledby="component-1042">

step 1 : i define a viewport (layout:border), with 2 items (menuPanel and mainPanel)


Ext.define('Viewport', {
extend: 'Ext.container.Viewport',
initComponent: function(){
Ext.apply(this, {
layout: 'border',
padding: 5,
items: [
{region:'west' ,xtype:'panel' ,...},
{region:'center' ,xtype:'panel' ,...}
] });
} };

step 2 : i define a mvc view : (layout:border), with 2 items (formPanel,gridPanel).


Ext.define('userlist',
{ extend : 'Ext.panel.Panel', initComponent: function(){ Ext.apply(this, {
layout: 'border',
padding: 5,
items: [ {region:'east' ,xtype:'panel' ,...}, {region:'center' ,xtype:'panel' ,...} ]
}}});

step 3 : after fireevent on a menu item selected, i do


var content = Ext.widget('userlist'); mainpanel.removeAll(); mainpanel.add(content)


the result is that : tags <div> are generated but the height style attribute param is equal to 0px. I would like to know if you know how the height could be adjust automatically? I make some test with


content.setHeight(mainpanel.getHeight())

but the size is set one time but no more when window resize bubbling An other test with content.doLayout() but in this case the height is still 0. Hope you could help me thanks in advance

mitchellsimoens
28 Feb 2012, 8:08 AM
Is the mainpanel the Viewport class you defined?

betimonde
28 Feb 2012, 9:01 AM
nop i dont think so.

here how i define the viewport



Ext.define('AC.view.Viewport', {
extend: 'Ext.container.Viewport',
initComponent: function(){

Ext.define('Menu', {
extend: 'Ext.data.Model',
fields: ['title']
});

Ext.apply(this, {
layout: 'border',
padding: 5,
items: [this.createMenuPanel(), this.createMainPanel()]
});
this.callParent(arguments);
},

createMenuPanel: function(){
this.menupanel = Ext.create('widget.menupanel', {
region: 'west',
title: 'Menu',
xtype:'panel',
autoHeight:true,
}
});
return this.menupanel;
},

createMainPanel: function(){
this.mainpanel = Ext.create('widget.mainpanel', {
region: 'center',
xtype:'panel',
layout:'fit',
minWidth: 300,
});
return this.mainpanel;
},

onMenuSelect: function(feed, menu){
var content = Ext.widget('userlist');
this.mainpanel.removeAll();
this.mainpanel.add(content);
}
}


and the userlist


Ext.define('AC.view.userList', {
extend : 'Ext.panel.Panel',
alias : 'widget.userlist',

initComponent: function(){

Ext.apply(this, {
layout: 'border',
autoHeight:true,
padding: 5,
items: [this.createGridPanel(),this.createFormPanel()]
});
this.callParent(arguments);
},

createFormPanel: function(){
this.formpanel = Ext.create('Ext.panel.Panel', {
region: 'east',
xtype:'panel',
autoHeight:true,
}
return this.formpanel;
},

createGridPanel: function(){
this.gridpanel = Ext.create('Ext.panel.Panel', {
region: 'center',
xtype:'panel',
minWidth: 300,
autoHeight:true,
});
return this.gridpanel;
},
});



thanks to have a look :)

mitchellsimoens
28 Feb 2012, 9:05 AM
Ok... two issues.

First in your userList class, createFormPanel isn't returning anything.

Second, you need to use something like layout : 'fit' on the mainpanel. This will tell userList to fit to it's dimensions. autoHeight on mainpanel probably isn't doing much.

betimonde
28 Feb 2012, 9:16 AM
OK you give the good answer !
-the mainpanel need a layout fit.
(and add the return into createFormPanel)

correction are directly made in the previous code section

thanks to be there. And could you tell me how to close this thread please?
And as you say to clean a little the code, the param autoHeight seems no to be need.
take care ;)