PDA

View Full Version : getForm().load() and "this.form.el is undefined"



lormitto
5 Mar 2010, 5:44 AM
Hi.

While following tutorial I tried to filled my form with data from php.
Unfortunately firebug throws error message: "this.form.el is undefined".

Code looks like this:




formUser.getForm().load({
url: 'phpDataGenerator.php?p=param&id=100',
params: {
id:'id'
},
failure: function(form, action) {
Ext.Msg.show({title: "Data unavailable", msg: action.result.errorMessage});
}
});

I can't figure out where i made mistake. Do you have any experiance with this kind of error?

5 Mar 2010, 10:36 AM
load after render

lormitto
5 Mar 2010, 10:43 AM
load after render


It might be difficult because of structure of code i wrote. However i would like to ask you if there is any way to include load() into definition of particular FormPanel - that would resolve some of my problems?



The code looks more or less like this (description):

After clicking twice on grid another window is opened (id from row is sent). This window consists tabPanel. In first tab, there is a form in item[simpleForm]. Form is defined in another file. It should be filled with data based on id sent from grid. I must face problem of erasing data after closing window and clicking on grid again to open new window with new id (autoDestroy: false - failed somehow). If I would include load() into definition, i would define form in item[{formDefinition}] and handle my "destroy" nightmare :). it is not elegant but for now it should be fine.

I hope description above is clear.

tobiu
5 Mar 2010, 11:16 AM
you can use the listeners-config of formPanel.

like:



listeners : {
render : function(){
// form.load();
}
}



kind regards,
tobiu

jserio
16 Mar 2010, 7:05 PM
you can use the listeners-config of formPanel.

like:



listeners : {
render : function(){
// form.load();
}
}

kind regards,
tobiu


I hate to piggy back on this, but I have a related question. I have the following code inside my extended form class:



onRender: function() {
// Call parent
ATAP.ViewApplication.superclass.onRender.apply(this, arguments);

// Set wait message target
this.getForm().waitMsgTarget = this.getEl();

// Loads form after initial layout
//this.on('afterlayout', this.loadData, this, {single:true});
this.on({
afterlayout: {scope: this, single: true, fn: function() {
this.loadData(); // Load the form data
this.doLayout(); // Adjust the height of the container after all elements have been placed
}}
});

}, // End function onRender

This works great in that all data is loaded after the form is rendered. However, I want to do some post-processing - namely disabling any tabs that do not have content (the tabs are just open-ended questions that were optional). The problem is, I cannot seen to get the value of the fields. Depending on where I place the following code, i either get undefined, [Object object], or just empty data.


// Disable tabs for text fields that contain no content
var f = this.getForm();
var fn = f.findField('first_name').getValue();
alert(fn);

I tried placing this within "this.on" and got an empty string. Placing it outside of this.on (at the end of the onRender function) gets me undefined. I even tried moving it to the end of my loadData function and also get an undefined.

Any ideas?

Jim

jserio
16 Mar 2010, 7:48 PM
After more searching, found what I needed here:

http://www.extjs.com/forum/showthread.php?t=20819

tobiu
17 Mar 2010, 12:45 AM
good morning from the gmt+1 timezone ;)

true, the load-method has callbacks like success for postprocessing.
just out of curiosity: why do you set the listener for the event afterlayout in the event-listener-method for render and not directly in the formpanel?


kind regards,
tobiu

kook_pudding
5 Jul 2010, 7:36 PM
formUser.getForm() has not load() method;
formUser has .