关于Ext formPanel.getForm().submit()方法与standardSubmit属性的一些事
版本 Extjs 3.3.1 ??
查看API文档,发现formPanel.getForm()是一个BasicForm对象,submit方法定义如下:
?
submit(?Object?options
?) : BasicForm
options
: ObjectThe options to pass to the action (see doAction for details).
Note: this is ignored when using the standardSubmit option.
The following code:
?
new Ext.FormPanel({ standardSubmit: true, baseParams: { foo: 'bar' }, url: 'myProcess.php', items: [{ xtype: 'textfield', name: 'userName' }], buttons: [{ text: 'Save', handler: function(){ var fp = this.ownerCt.ownerCt, form = fp.getForm(); if (form.isValid()) { // check if there are baseParams and if // hiddent items have been added already if (fp.baseParams && !fp.paramsAdded) { // add hidden items for all baseParams for (i in fp.baseParams) { fp.add({ xtype: 'hidden', name: i, value: fp.baseParams[i] }); } fp.doLayout(); // set a custom flag to prevent re-adding fp.paramsAdded = true; } form.submit(); } } }]});
?
这个时候需要在formPanel本身添加参数baseParams,并在handler中添加相应的处理方法。
?