PDA

View Full Version : form element resize on maximize



.bonga
30 Oct 2009, 6:00 AM
I have a window on the viewport with a form and in this form there is a textfield with an anchor. When I resize the window, the ExtJS resizes the textfield because of the anchor.
But when I maximize the window, the ExtJS don't resize the textfield. Why? How can I fix it?
My source:

Ext.onReady(function(){
var viewport = new Ext.Viewport({
layout: 'border',
items: [{
region: 'center',
tbar: [{
xtype: 'button',
text: 'New Window',
handler: function(){
var win = new Ext.Window({
title: 'New Window',
maximizable: true,
width: 400,
height: 200,
items:[{
xtype: 'form',
frame: true,
items:[{
xtype: 'textfield',
fieldLabel: 'field title',
name: 'label',
anchor: '100%',
}],
}],
});
win.show();
},
}],
}],
});
});

Animal
30 Oct 2009, 6:07 AM
The xtype: 'form' is NOT having its sized managed. So it cannot manage its child item.

What layout do you think you should have configured the Window with?

.bonga
30 Oct 2009, 7:11 AM
Ok, I've thought the same, but I don't understand, that why works the resize?

Animal
30 Oct 2009, 7:30 AM
coincidence. You must use a layout.

I assume that you want the form to fit exactly within the Window.

.bonga
30 Oct 2009, 7:39 AM
:)) That's the best answer: 'coincidence'! LOL! :))

I'll use the fit layout, of course and Thanks!

(Hey, maybe I can write a new operating system by coincidence? I should try it once...:))

.bonga
30 Oct 2009, 8:43 AM
It seems to me, that fit layout can't help me out.
But I've found the solution: the maximize() and the restore() function don't call the doLayout() function.
Here is the workaround:

listeners: {
maximize: function(){this.doLayout();},
restore: function(){this.doLayout();},
},
So, I think it's a bug, isn't it?

Animal
30 Oct 2009, 8:45 AM
No.

Fit layout works.

You did it wrong.