PDA

View Full Version : Fit layout no longer applied to gridPanel in a dynamic content Panel



Angron
17 Jan 2011, 2:34 AM
I have a problem when i'm trying to generate a dynamic grid with fit layout in a standard Ext.Panel.
It works perfectly when the Panel is rendered but after that if I want to remove panel's components and then adding new grid, the fit layout isn't applied to the new grid :( Otherwise all is working fine...

Grid definition is looking like that :

var myGrid = new Ext.grid.GridPanel({
...
layout: 'fit',
viewConfig: {
forceFit: true
},
...
});

The method that remove component and add new grid is looking like this :


loadView: function(){
this.removeAll(true);

var myGrid = new Ext.grid.GridPanel({
...
layout: 'fit',
viewConfig: {
forceFit: true
},
...
});

myGrid.store.load();
this.add(myGrid);
this.doLayout();
}

All is working well, data are good, grid size is good but the layout fit isnt applied anymore and I have no idea why.
Someone has an idea about it?

Thx in advance and sorry for the poor english.

Angron

Condor
17 Jan 2011, 7:58 AM
GridPanel doesn't have a 'layout' config option. What is the layout of the container you are adding this grid to?

Angron
17 Jan 2011, 11:45 PM
Hello,

Thx for your help.

My grid panel is in a "Ext.Panel" and this panel is in a tab of a "Ext.TabPanel".
The default layout for my "Ext.TabPanel" items is "fit", I did not specified a layout for the "Ext.Panel".
I found a work around using a "RemoveAll()" in the tab.


tabPanel.get("myPanel").removeAll();
tabPanel.get("myPanel").add(myNewPanel);


No layout problem after re generating the Panel :)

So yes problably something I don't understand in layout management :p But dunno what at the moment ;)

Condor
18 Jan 2011, 12:06 AM
1. The tabpanel always has layout:'card' (you can't specify anything different).
2. The panel needs layout:'fit'.
3. Don't forget to call doLayout after adding items, e.g.
var panel = tabPanel.get("myPanel");

panel.removeAll();
panel.add(myNewPanel);
panel.doLayout();