PDA

View Full Version : FormPanel and load function



lormitto
4 Mar 2010, 8:43 AM
Hi

I found following code:
var myFormPanel = new Ext.form.FormPanel({

title: 'Client and routing info',
items: [{
fieldLabel: 'Client',

name: 'clientName'
}, {
fieldLabel: 'Port of loading',
name: 'portOfLoading'
}, {
fieldLabel: 'Port of discharge',
name: 'portOfDischarge'


}]
});
myFormPanel.getForm (http://www.extjs.com/forum/../deploy/dev/docs/output/Ext.form.FormPanel.html#Ext.form.FormPanel-getForm)().load (http://www.extjs.com/forum/../deploy/dev/docs/output/Ext.form.BasicForm.html#Ext.form.BasicForm-load)({


url: '/getRoutingInfo.php',
params: {
consignmentRef: myConsignmentRef
},
failure: function(form, action) {
Ext.Msg.alert("Load failed", action.result.errorMessage);


}
});

Do you perhaps know how to place load function with its definition inside:


new Ext.form.FormPanel({
title: 'Client and routing info',
items: [{
fieldLabel: 'Client',


name: 'clientName'
}, {
fieldLabel: 'Port of loading',
name: 'portOfLoading'
}, {
fieldLabel: 'Port of discharge',
name: 'portOfDischarge'


}]
});


I wonder if it is possible.

8 Mar 2010, 5:48 AM
The defaultType for FormPanel is "panel". You must set the default type to 'textfield' if you want textfields to display.

tobiu
8 Mar 2010, 6:01 AM
since load() is a call to fill the form, it does not make sense to include it into the panel.
you can use a listener for an event (like render, afterrender,...) and call form.load() on that specific event.

your object in form.load() is an Ext.form.Action.Load
http://www.extjs.com/deploy/ext-3.1.1/docs/?class=Ext.form.Action.Load

you can define it somewhere else and call that action if needed.


kind regards,
tobiu