How to serialize form inside modal window in ExtJS?
I'm trying to build modal windows on the fly from single javascript object passed by server. But I have no clue how can I ser开发者_StackOverflow中文版ialize form inside modal window without defining form variable . In most examples serialize process look like this:
//create form
var CustomForm = new Ext.FormPanel({...});
//submiting form
CustomForm.getForm().submit({...});
In my case all inner components like "form" are created from xtype value,and no variable is assigned to it. Is there any way to select and serialize form using something like this:
Ext.get(this).select('form').serialize();
or what is apropriate way of doing so?
You can assign the form an id and use Ext.getCmp(formid).
To retrieve the form values of a FormPanel use myFormPanel.getForm().getValues()
That will come back with a js object representing the form fields.
I wrote a function to take values from a form and generate a string for adding to the query string:
/**
* takes an array of form values and converts them into a
* query string
*
* @param {object} Ext.form
* @return {string}
*/
this.serialize_form_values = function(form)
{
var serial = '',
values = form.getValues();
for(var value in values)
serial += '&' + value + '=' + values[value];
return serial.substr(1);
};
Maybe it could be useful for someone?
精彩评论