PDA

View Full Version : Control in a collapsible panel resizes itself and goes out of layout



sand1980
19 Feb 2013, 2:30 AM
Hi there,
I have the following code.


var items = [{
items: [{
title: 'Description',
xtype: 'fieldset',
items: [{ xtype: 'textarea', hideLabel: true, height: 100, name: 'Description', itemId: 'description'}]
}]}, {
items: [{
title: 'Comment',
xtype: 'fieldset',
items: [{ xtype: 'textarea', id: 'CommentArea', hideLabel: true, height: 40, anchor: '100%', name: 'Comments'}]
}]
}];


var formPanel = Ext.create('Ext.FormPanel', {
region: 'center',
split: true,
layout: 'column',
autoScroll: true,
floatable: false,
animCollapse: true,
border: false,
height: 600,
anchor: '100%',
defaults: {
border: false,
layout: 'form',
columnWidth: 0.50,
bodyStyle: 'padding:5px 5px 0 5px',
defaults: {
anchor: '-20',
xtype: 'textfield'
}
},
items: items
});
var panel = Ext.create('Ext.Panel', {
title: 'General Info',
layout: 'border',
autoScroll: false,
isReadOnly: false,
collapsible: true,
border: false,
height: 605,
items: [formPanel]
});
var win = Ext.create('Ext.window.Window',{
title: 'Test window',
height: 500,
width: 700,
layout: 'fit',
items: panel,
x: 25, y:25
});
win.show();


When click on the collapsible panel and minimized it and then again click it to maximize it the controls resize itself and go out of layout and get chopped off. You can view screenshot of it below.
41937
I have a similar kind of issue in another app but due to company policy I cannot share the code. I think the layout problem there is related to this. Is there any solution?

evant
19 Feb 2013, 2:36 AM
It's probably better if you explain what output you want, because there's a few abuses/misuses of the layout system, in no particular order:

1) The window has a fit layout, so there's no point specifying a height/width on "panel".
2) A border layout with a single child item, fit would be more appropriate.
3) Why nest a form panel inside a panel? This is over-nesting.
4) Anchor is redundant on the form config, since the parent doesn't use an anchor layout.

sand1980
19 Feb 2013, 3:27 AM
Thank Evan.
I am porting an ExtJS 3 app to ExtJS4. In the existing application the UI is similar to the code I have shared above.
I tried your solution but the same problem persist. The code with your changes is pasted below.


var items = [{
items: [{
title: 'Description',
xtype: 'fieldset',
items: [{ xtype: 'textarea', hideLabel: true, height: 100, name: 'Description', itemId: 'description'}]
}]}, {
items: [{
title: 'Comment',
xtype: 'fieldset',
items: [{ xtype: 'textarea', id: 'CommentArea', hideLabel: true, height: 40, name: 'Comments'}]
}]
}];


var formPanel = Ext.create('Ext.FormPanel', {
collapsible: true,
split: true,
layout: 'column',
autoScroll: true,
floatable: false,
animCollapse: true,
border: false,
defaults: {
border: false,
layout: 'form',
columnWidth: 0.50,
bodyStyle: 'padding:5px 5px 0 5px',
defaults: {
anchor: '-20',
xtype: 'textfield'
}
},
items: items
});


var win = Ext.create('Ext.window.Window',{
title: 'Test window',
height: 500,
width: 700,
layout: 'fit',
items: formPanel,
x: 25, y:25
});
win.show();