PDA

View Full Version : Button in the panel's center



samotnik
1 Aug 2010, 4:40 AM
Good day.
I am sorry, but I can not add message to existing my thread here : http://www.sencha.com/forum/showthread.php?105834-set-button-in-the-center-panel
And I have to create a new thread.
Thank you, mr.Animal for advise, but when I added your code to my - nothing to display, only panel's title
My code here :


var startLabel = new Ext.form.Label({
text: 'Start'
});

var dateStart = new Ext.form.DateField({
autoWidth: true,
listeners: {
'select' : function (field, date) {
alert('You selected start date ' + date);
}
}
});

var endLabel = new Ext.form.Label({
text: 'End'
});

var dateEnd = new Ext.form.DateField({
autoWidth: true,
listeners: {
'select' : function (field, date) {
alert('You selected end date ' + date);
}
}
});

var cancelButton = new Ext.Button({
text: 'Cancel',
listeners: {
'click' : function () {
alert('you pressed cancel button');
}
}
});

var formPanel = new Ext.Panel({
title: this.nlsTitle,
cls: 'clearAllocation',
autoWidth: true,
autoHeight: true,
layout: {
type: 'vbox',
align : 'center',
pack : 'center'
},
items: [
startLabel,
dateStart,
endLabel,
dateEnd,
cancelButton
]
});

Animal
1 Aug 2010, 5:11 AM
autoXXXX?

So you want the items to have their positions calculated to be exactly in the center of...... WHAT?

samotnik
1 Aug 2010, 5:20 AM
I have a panel.
In this panell I have added 2 DateField items and one button. Each item under another :


Start DateField
End Date Field
Button
And I need to set button in the center of that panel. And this panel is in the Ext.Window. And when I will to resize this Window, my panel with 2 DateFiled and one button should resize too, and button should always is in the panel's center :)

Animal
1 Aug 2010, 5:25 AM
Why have that Panel then? Put the items in the Window!

samotnik
1 Aug 2010, 5:33 AM
I can not do it, because in this window, I should insert 3 panels except thishttp://www.google.com/images/cleardot.gif :)

Animal
1 Aug 2010, 5:56 AM
So, use a layout to lay out and size those 3 panels AS YOU REQUIRE

samotnik
1 Aug 2010, 6:01 AM
thank you. But can you please explain, why panel's property

buttonAlign: 'center'
is not working?

Animal
1 Aug 2010, 6:23 AM
That affects the fbar. As the docs tell you. It doesn't just absolutely position any button added anywhere dead center.

Now get your Panel sized properly, and use vbox as I told you.