开发者

ExtJS add additional data into the post of a form

开发者 https://www.devze.com 2023-02-03 20:56 出处:网络
I have a simple ExtJS form, but I would like to add additional attributes to be sent as post dat开发者_C百科a.

I have a simple ExtJS form, but I would like to add additional attributes to be sent as post dat开发者_C百科a.

I have tried form.setValues({name:value}) but for some reason it does not actually set the value...

Thanks


The documentation for setValues says:

Set values for fields in this form in bulk.

From that I take it that the fields have to exist in the form for the values to be set, so add hidden fields to the form. http://dev.sencha.com/deploy/dev/docs/?class=Ext.form.Hidden

You can do that in your FormPanel config or using formPanel.add

[{
  xtype: 'hidden',
  name: 'hidden1',
  value: 'hiddenValue1'
}, {
  xtype: 'hidden',
  name: 'hidden2',
  value: 'hiddenValue2'
}]

If you need to set the values dynamically, you can now use form.setValues.


Also can directly add the additional value to submit parameter: url or params

like this:

this.theWindow.get(0).getForm().submit({
  url : 'youraction.action?name=value',
  success : function(form, action) {
     ...
  },
  failure : function(form, action) {
     ...
  }
}

or

this.theWindow.get(0).getForm().submit({
  url : 'youraction.action',
  params : {name : value},
  success : function(form, action) {
     ...
  },
  failure : function(form, action) {
     ...
  }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号