-
22 Dec 2011 11:07 AM #1
Answered: Ext.form.Panel only works in fit layout
Answered: Ext.form.Panel only works in fit layout
It looks as though a form panel will only work correctly in a fit layout. Is this correct? I have wasted many hours trying to use a vbox layout.
This displays the form fields correctly
This displays the form fields correctlyCode:Ext.application({ name: 'app', launch: function(){ var vp = Ext.create('Ext.Panel', { fullscreen: true, layout: 'fit' }); // var hdr = Ext.create('Ext.TitleBar', { // title: 'test title' // }); var fp = Ext.create('Ext.form.Panel', { items: [{ xtype: 'toolbar', docked: 'top', title: 'test panel header' },{ xtype: 'textfield', name: 'name', label: 'Name' },{ xtype: 'passwordfield', name: 'password', label: 'Password' }] }); // vp.add(hdr); vp.add(fp); } });
Code:Ext.application({ name: 'app', launch: function(){ var vp = Ext.create('Ext.Panel', { fullscreen: true, layout: 'vbox' }); // var hdr = Ext.create('Ext.TitleBar', { // title: 'test title' // }); var fp = Ext.create('Ext.form.Panel', { items: [{ xtype: 'toolbar', docked: 'top', title: 'test panel header' },{ xtype: 'textfield', name: 'name', label: 'Name' },{ xtype: 'passwordfield', name: 'password', label: 'Password' }] }); // vp.add(hdr); vp.add(fp); } });
-
Best Answer Posted by mitchellsimoens
It works, you just need to tell the form to have a height (notice red text):
align : 'stretch' will make the items fill the entire width. flex : 1 is the ratio of the parent's height, in this case since it is the only item it will fill the entire height.Code:Ext.application({ name: 'app', launch: function(){ var vp = Ext.create('Ext.Panel', { fullscreen: true, layout: { type : 'vbox', align : 'stretch' } }); // var hdr = Ext.create('Ext.TitleBar', { // title: 'test title' // }); var fp = Ext.create('Ext.form.Panel', { flex : 1, items: [{ xtype: 'toolbar', docked: 'top', title: 'test panel header' },{ xtype: 'textfield', name: 'name', label: 'Name' },{ xtype: 'passwordfield', name: 'password', label: 'Password' }] }); // vp.add(hdr); vp.add(fp); } });
-
22 Dec 2011 11:19 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,641
- Vote Rating
- 434
- Answers
- 3107
It works, you just need to tell the form to have a height (notice red text):
align : 'stretch' will make the items fill the entire width. flex : 1 is the ratio of the parent's height, in this case since it is the only item it will fill the entire height.Code:Ext.application({ name: 'app', launch: function(){ var vp = Ext.create('Ext.Panel', { fullscreen: true, layout: { type : 'vbox', align : 'stretch' } }); // var hdr = Ext.create('Ext.TitleBar', { // title: 'test title' // }); var fp = Ext.create('Ext.form.Panel', { flex : 1, items: [{ xtype: 'toolbar', docked: 'top', title: 'test panel header' },{ xtype: 'textfield', name: 'name', label: 'Name' },{ xtype: 'passwordfield', name: 'password', label: 'Password' }] }); // vp.add(hdr); vp.add(fp); } });Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
22 Dec 2011 11:55 AM #3
Thanks for your help
It would be good if flex: 1 were the default when using vbox/hbox layouts. Then sizing would only be needed if different sized components were required.


Reply With Quote