PDA

View Full Version : form.submit from tbar without keeping from in a variable



amt779
12 Sep 2010, 12:25 PM
here is my code


page.tab = Ext.extend(Ext.form.FormPanel, {
labelAlign: 'top',
iconCls: 'page-ico',
padding: 10,
closable: true,
tbar: {
items: [
{ text : 'Save',
scope:this,
iconCls: 'save-ico',
handler:function(node) {
this.form.submit({
params : { table : cs.table, id : cs.tableid, act : 'upd' }
,waitMsg : 'wait ...'
,failure : function(form, action) {
Ext.MessageBox.alert('err', 'err txt ' + action.failureType);
}
}, this);
}
},

firebug says

this.form is undefined
chrome://firebug/content/blank.gif this.form.submit({


is there any way to submit the form using toolbar item ?

Condor
12 Sep 2010, 11:02 PM
You are specifying the scope as 'this', but what is 'this' when you create this class? It certainly is not the form!

Instead use:

handler: function(btn) {
var formPanel = btn.getParentByType('form');
formPanel.getForm().submit({...});
}

amt779
13 Sep 2010, 10:07 AM
I doubt actually that there is a such method as getParentByType for button, according to http://dev.sencha.com/deploy/dev/docs/?class=Ext.Button

But i tried it anyway

page.tab = Ext.extend(Ext.form.FormPanel, {
labelAlign: 'top',
iconCls: 'page-ico',
padding: 10,
closable: true,
tbar: {
items: [
{ text : '?????????',
iconCls: 'save-ico',
handler: function(btn) {
var formPanel = btn.getParentByType('form');
formPanel.getForm().submit();
***

And i got an error

btn.getParentByType is not a function
var formPanel = btn.getParentByType(btn,'form');