
Untitled
By: a guest on
Aug 5th, 2012 | syntax:
None | size: 3.79 KB | hits: 20 | expires: Never
ExtJs 4.1 - Issue with a fluid form inside a window
<html>
<head>
<title>TEST</title>
<link rel='stylesheet' href='resources/extjs/resources/css/ext-all.css' />
<script type='text/javascript' src='resources/extjs/ext-all-dev.js'></script>
<script type='text/javascript'>
function getForm(){
var form = {
xtype:'form',
region:'north',
height:100,
autoScroll:true,
minWidth:300,
title: 'Simple Form',
items: [
{
xtype:'container',
layout:'hbox',
items:[
{
xtype:'textfield',
fieldLabel: 'First',
name: 'first',
allowBlank: false,
width:100,
labelWidth:50,
flex:1
},{
xtype:'textfield',
fieldLabel: 'Last',
name: 'last',
allowBlank: false,
width:100,
labelWidth:50,
flex:1
}
]
}]
};
return form;
}
function getWin(){
var win = Ext.create('Ext.window.Window',{
title:'Test Window',
height:400,
width:600,
layout:'border',
items:[
getForm(),
{
region:'center',
title:'Center Region',
html:'Center Region Content'
}
]
});
return win;
}
Ext.onReady(function(){
var win = getWin();
win.show();
});
</script>
</head>
<body>
</body>
</html>
Ext.require([
'Ext.form.*',
'Ext.window.Window'
]);
Ext.onReady(function() {
var form = Ext.create('Ext.form.Panel', {
border: false,
fieldDefaults: {
labelWidth: 50
},
url: 'save-form.php',
autoScroll: true,
autoHeight: true,
bodyPadding: 5,
items: [
{xtype:'panel',
title:'Simple Form',
minWidth: 400,
layout: 'hbox',
defaultType: 'textfield',
items:[
{
fieldLabel: 'First',
name: 'first',
allowBlank: false,
flex: 1,
anchor:'100%' // anchor width by percentage
},{
fieldLabel: 'Last',
name: 'last',
allowBlank: false,
flex: 1,
anchor: '100%' // anchor width by percentage
}
]
}, {
xtype: 'panel',
title: 'Center Region',
html: 'Center Region Content'
}]
});
var win = Ext.create('Ext.window.Window', {
title: 'Test Window - Resize Me',
width: 600,
height:400,
minWidth: 300,
minHeight: 200,
layout: 'fit',
plain: true,
items: form,
buttons: [{
text: 'Send'
},{
text: 'Cancel'
}]
});
win.show();
});