PDA

View Full Version : Auto window height / resize after adding component? 12h of struggle



moozy
1 Feb 2012, 5:58 PM
Hi guys,

if I have a Ext window, with items {something},{container} and I add new component (textfield) to the container, the window does not resize to fit the content. What can I do to make it happen? I'm adding stuff to the container dynamically.

I spent days researching solution, tried to call window.doLayout() after container.add action, no change?

Is anyone able to help me?
Thanks

moozy
2 Feb 2012, 12:53 AM
is it possible? anyone?

friend
2 Feb 2012, 10:47 AM
Try this:



var x = Ext.create('Ext.window.Window', {
bodyPadding: 5,
title: 'Test Window',
layout: 'fit',
items: [{
xtype: 'panel',
bodyPadding: 5,
layout: 'fit',
title: 'Test Container',
items: [{
xtype: 'textfield',
fieldLabel: 'First Name',
width: 220
},{
xtype: 'textfield',
fieldLabel: 'Last Name',
width: 220
}]
}],
buttonAlign: 'right',
buttons: [{
text: 'Add Component',
handler: function(button, evt) {
x.down('panel').add({
xtype: 'textfield',
fieldLabel: 'SSN',
maskRe: /[0-9\-]/,
regex: /\d{3}-\d{2}-\d{4}/,
width: 200
});
}
}]
}).show();