setfanovic72
19 Aug 2011, 5:58 AM
Hi,
I just started with extjs 4. Today I have tried to build a simple login form. Technically it works but I am struggling with te layout.
What I did is the following.
I created a viewport with a border layout:
Ext.define('SISCA.view.Viewport', {
extend: 'Ext.Viewport',
id: 'viewport',
layout: {
type: 'border',
padding: 5
},
defaults: {
split: true
},
initComponent: function() {
var me = this;
Ext.apply(me, {
items: [
{
region: 'north',
html: '<h3 class="header">SiSCA</h3>',
height: 70,
cls: 'appHeader',
split: false
}
{
region: 'center',
xtype: 'loginform'
title: 'Login',
}
]
});
me.callParent(arguments);
}
});
The code of the login form:
Ext.define('SISCA.view.user.Login' ,{
extend: 'Ext.form.Panel',
alias : 'widget.loginform',
title : 'Inloggen in SiSCAa',
width: 150,
bodyPadding: 10,
initComponent: function() {
this.items = [
{
xtype: 'textfield',
name : 'username',
fieldLabel: 'Gebruikersnaam',
allowBlank: false
},
{
xtype: 'textfield',
name : 'password',
fieldLabel: 'Wachtwoord',
inputType: 'password'
}
];
this.buttons = [
{
text: 'Login',
action: 'login'
}
];
this.callParent(arguments);
}
});
The result is a border layout with a top region which has a height of 70px and a center region. So far, so good.
The behavior of the center region in a border layout is that it will fill up all the space which is left after the top region is created. This behavior ensures that the entire center area is filled with the login panel. The panel is being streched to the size of the center region.
What I want is the following:
I want my login panel to have an absolute size and I want it to be aligned in the center of the center region of the border layout.
I allready tried several things (for example a nested panel) but so far I didn't succeed. Can somebody help me?
Thanks a lot!!
Regards Stefan.
I just started with extjs 4. Today I have tried to build a simple login form. Technically it works but I am struggling with te layout.
What I did is the following.
I created a viewport with a border layout:
Ext.define('SISCA.view.Viewport', {
extend: 'Ext.Viewport',
id: 'viewport',
layout: {
type: 'border',
padding: 5
},
defaults: {
split: true
},
initComponent: function() {
var me = this;
Ext.apply(me, {
items: [
{
region: 'north',
html: '<h3 class="header">SiSCA</h3>',
height: 70,
cls: 'appHeader',
split: false
}
{
region: 'center',
xtype: 'loginform'
title: 'Login',
}
]
});
me.callParent(arguments);
}
});
The code of the login form:
Ext.define('SISCA.view.user.Login' ,{
extend: 'Ext.form.Panel',
alias : 'widget.loginform',
title : 'Inloggen in SiSCAa',
width: 150,
bodyPadding: 10,
initComponent: function() {
this.items = [
{
xtype: 'textfield',
name : 'username',
fieldLabel: 'Gebruikersnaam',
allowBlank: false
},
{
xtype: 'textfield',
name : 'password',
fieldLabel: 'Wachtwoord',
inputType: 'password'
}
];
this.buttons = [
{
text: 'Login',
action: 'login'
}
];
this.callParent(arguments);
}
});
The result is a border layout with a top region which has a height of 70px and a center region. So far, so good.
The behavior of the center region in a border layout is that it will fill up all the space which is left after the top region is created. This behavior ensures that the entire center area is filled with the login panel. The panel is being streched to the size of the center region.
What I want is the following:
I want my login panel to have an absolute size and I want it to be aligned in the center of the center region of the border layout.
I allready tried several things (for example a nested panel) but so far I didn't succeed. Can somebody help me?
Thanks a lot!!
Regards Stefan.