I have a formpanel which I use to both add and edit data. When I edit data, I add a few extra fields via the FormPanel.add() method, then run the load command with a URL that returns the data.
The odd thing is that some of my textfields get assigned random heights IF the form is first rendered with an edit action, so that it blows up the form design and looks very odd. If I reload the page / app and do an 'add' action first, then do an edit action, it doesn't happen. I am not assigned a height, leaving it at auto.
The form is a 2 column form, the code is below. I have no idea why this is happening. I dug into the TextField and BoxComponent source code and can't see why it is doing it either.
var implantform = function(config) {
Ext.apply(this,config);
var savemsg = '';
this.formaction = this.formaction ? this.formaction : 'add';
if( this.formaction == 'add')
{
this.url = '/itracker/implants/add';
savemsg = 'Implant Data Created';
}
else
{
this.url = '/itracker/implants/edit';
savemsg = 'Implant Data Updated';
}
var fs = mdi.app.getWindow('implantformwindow');
if( ! fs )
{
var fs = mdi.app.createWindow({
width: 400,
height: 400,
minimizable: false,
maximizable: false,
id: 'implantformwindow',
items: [
new Ext.FormPanel({
url: this.url,
title: this.title,
labelAlign: 'right',
frame:true,
title: 'Implant Information',
//bodyStyle:'padding:5px 5px 0',
width: 700,
waitMsgTarget: true,
id: 'implantform',
buttons: [{
text: 'Submit',
disabled: false,
handler: function(){
var f = Ext.getCmp('implantform');
f.form.submit( {
reset: false,
url: f.url,
waitMsg: 'Saving Data...',
success: function(){
var f = Ext.getCmp('implantgrid');
mdi.app.status(savemsg);
if( f )
{
f.store.load();
}
}
});
}
},{
text: 'Cancel',
disabled: false,
handler: function() {
var f = Ext.getCmp('implantformwindow');
f.hide();
}
}],
items: [{
layout:'column',
items:[{
columnWidth:.5,
layout: 'form',
defaultType: 'textfield',
items: [{
fieldLabel: 'Tissue ID',
name: 'data[Implant][tissue_id]',
id: 'TissueId',
//name: 'tissue_id',
width:190,
allowBlank:false,
plugins: [Ext.ux.plugins.RemoteValidator],
rvOptions: {
url: '/itracker/implants/checktissueid'
}
},
{
fieldLabel: 'Lot ID',
name: 'data[Implant][lot_id]',
width:190,
id: 'LotId',
allowBlank:false
},
new Ext.form.ComboBox({
store: mdi.app.products_ds,
fieldLabel: 'Product',
hiddenName: 'data[Implant][product_id]',
name: 'data[Implant][product_id]',
valueField: 'product_id',
displayField: 'name',
typeAhead: false,
triggerAction: 'all',
emptyText: 'Select a product...',
selectOnFocus: true,
editable: false,
autoLoad: true,
id: 'ProductId',
allowBlank:false
})
,new Ext.form.ComboBox({
store: mdi.app.containers_ds,
fieldLabel: 'Container',
hiddenName: 'data[Implant][container_id]',
name: 'data[Implant][container_id]',
valueField: 'container_id',
displayField: 'name',
typeAhead: false,
triggerAction: 'all',
emptyText: 'Select a container...',
selectOnFocus: true,
editable: false,
autoLoad: true,
id: 'ContainerId',
allowBlank:false
})
,new Ext.form.DateField({
fieldLabel: 'Date of Exp.',
name: 'data[Implant][date_of_expiration]',
width:190,
allowBlank:false,
id: 'ImplantDateOfExpiration'
}),
new Ext.form.DateField({
fieldLabel: 'Date Received',
name: 'data[Implant][date_delivered]',
width:190,
allowBlank: false,
value: mdi.app.today,
id: 'ImplantDateReceived'
}),
{
fieldLabel: 'Drop Shipped',
name: 'data[Implant][drop_shipped]',
width:190,
allowBlank:true,
id: 'ImplantDropShipped'
},
new Ext.form.DateField({
fieldLabel: 'Date Implanted',
name: 'data[Implant][date_implanted]',
width:190,
allowBlank: true,
id: 'ImplantDateImplanted'
}),
new Ext.form.DateField({
fieldLabel: 'Date Returned',
name: 'data[Implant][date_returned]',
width:190,
allowBlank:true,
id: 'ImplantDateReturned'
})
]
},
{
columnWidth:.5,
layout: 'form',
defaultType: 'textfield',
id: 'ImplantRightCol',
items: [
{
fieldLabel: 'Return Authorization',
name: 'data[Implant][return_authorization]',
width: 190,
allowBlank:true
},
new Ext.form.ComboBox({
fieldLabel: 'Facility',
store: mdi.app.facility_ds,
id: 'FacilityId',
hiddenName: 'data[Implant][facility_id]',
name: 'data[Implant][facility_id]',
valueField: 'facility_id',
displayField: 'name',
typeAhead: false,
triggerAction: 'all',
emptyText: 'Select a Facility...',
selectOnFocus: true,
editable: false,
autoLoad: true
}),
{
fieldLabel: 'Physician',
name: 'data[Implant][physician]',
width: 190,
allowBlank:true
},
{
fieldLabel: 'Notes',
name: 'data[Implant][notes]',
width:190,
height: 65,
allowBlank: true
},
new Ext.form.Hidden({ name: 'data[Implant][id]', id: 'ImplantId'})
]
}]
}]
})
]
});
}
var fsform = fs.getComponent('implantform');
if( this.formaction == 'edit' )
{
fsform.form.findField('TissueId').rvOptions.params = { implantid: this.implantid };
fsform.form.reader = implantreader;
fsform.form.findField('ImplantId').setValue(this.i mplantid);
Ext.getCmp('ImplantRightCol').add( new Ext.form.Radio({
fieldLabel: 'Inspection Result',
name: 'data[Implant][inspection_result]',
inputValue: 'Pass',
boxLabel: 'Pass',
id: 'inspection_resultPass'
})
);
Ext.getCmp('ImplantRightCol').add( new Ext.form.Radio({
type: 'radio',
labelSeparator: '',
name: 'data[Implant][inspection_result]',
inputValue: 'Fail',
boxLabel: 'Fail',
id: 'inspection_resultFail'
})
);
Ext.getCmp('ImplantRightCol').add( new Ext.form.TextField(
{
fieldLabel: 'Status',
name: 'data[Implant][status]',
id: 'ImplantStatus',
width: 190
})
);
fsform.form.on('actioncomplete',function(myform,ac tion) {
if( action.type == 'load' )
{
if (action.result.data['data[Implant][inspection_result]'] == 'Pass') {
Ext.get('inspection_resultPass').dom.checked = true;
} else {
Ext.get('inspection_resultFail').dom.checked = true;
}
}
});
fsform.form.findField('FacilityId').store.load();
fsform.form.findField('ProductId').store.load();
fsform.form.findField('ContainerId').store.load();
fs.setSize({height: 375,width:710});
fs.show();
fsform.form.load({method: 'GET',
url: '/itracker/implants/edit/'+this.implantid,
success: function(f) {
f.findField('TissueId').validateRemote();
},
waitMsg: 'Loading'});
}
else
{
fsform.form.findField('LotId').allowBlank=true;
fs.setSize({height: 375,width:710});
fs.show();
fsform.form.findField('ImplantId').setValue('');
fsform.form.reset();
}
}
Where's The Advantage In Windows Genuine Advantage?
Stocks Bounce After S&P Joins Bear Market
|