PDA

View Full Version : How get FormPanel from actioncomplete event?



green-84
22 Mar 2010, 10:46 PM
Hi.

How I get FormPanel object from action complete function?

Here is code:

var formPanel = {
xtype : 'form',
defaultType : 'field',

items : [
{
fieldLabel : 'Name',
name : 'object[name]'
}
],

tbar : new Ext.Toolbar({
items : [
{
itemId : 'delete',
text : 'Delete',
disabled : true
}
]
}),

listeners : {
actioncomplete : function(form, action) {
if (action.type == 'load') {
console.info(form);
form.ownerCt.getTopToolbar().getComponent('delete').setDisabled(false);
//form.getTopToolbar().getComponent('delete').setDisabled(false);
}
}
}

}


When I append formPanel to another panel and load data I get errors:
form.ownerCt.getTopToolbar() is undefined
form.getTopToolbar is not a function (when uncomment "form.getTopToolbar().getComponent('delete').setDisabled(false);")

Animal
23 Mar 2010, 4:15 AM
I see the var formPanel there. What's the problem?

green-84
23 Mar 2010, 4:23 AM
I see the var formPanel there. What's the problem?


if place this code to a function:

function getForm() {
var formPanel = {
...
}

return formPanel;
}


that be wrong to use var formPanel in actioncomplete function.

Animal
23 Mar 2010, 4:33 AM
Just reference it using something.

steffenk
23 Mar 2010, 4:44 AM
The object has no instance, should be new Ext.Panel or Ext.FormPanel.