标签:
http://www.java123.net/436578.html
ExtJS 中,下列两个方法有差别 formPanel.getForm().getValues()和formPanel.getForm().getFieldValues()
1.对于下拉控件 ComboBox前者可能拿不到下拉框的value内容,而只是拿到它显示的内容后者则拿到value的内容。
2.对于DateField前者同样是拿到显示的内容,后者则是完整的datetime, 如 Tue Jun 18 2013 00:00:00 GMT+0800 (中国标准时间Ext.urlEncode后,显示为这样的内容 2013-06-18T00:00:00
其实这些从他们的源代码就能看出来。内容如下:/** *
Returns the fields in this form as an object with key/value pairs as they would be submitted using a standard form submit. * If multiple fields exist with the same name they are returned as an array.
*
Note: The values are collected from all enabled HTML input elements within the form, not from * the Ext Field objects. This means that all returned values are Strings (or Arrays of Strings) and that the * value can potentially be the emptyText of a field.
* @param {Boolean} asString (optional) Pass true to return the values as a string. (defaults to false, returning an Object) * @return {String/Object} */
getValues : function(asString){ var fs = Ext.lib.Ajax.serializeForm(this.el.dom); if(asString === true){ return fs; } return Ext.urlDecode(fs); },
/** * Retrieves the fields in the form as a set of key/value pairs, using the {@link Ext.form.Field#getValue getValue()} method. * If multiple fields exist with the same name they are returned as an array. * @param {Boolean} dirtyOnly (optional) True to return only fields that are dirty. * @return {Object} The values in the form */
getFieldValues : function(dirtyOnly){ var o = {}, n, key, val; this.items.each(function(f) { if (!f.disabled && (dirtyOnly !== true || f.isDirty())) { n = f.getName(); key = o[n]; val = f.getValue(); if(Ext.isDefined(key)){ if(Ext.isArray(key)){ o[n].push(val); }else{ o[n] = [key, val]; } }else{ o[n] = val; } } }); return o; },
getValues() 还是 getFieldValues() [转]
标签:
原文地址:http://www.cnblogs.com/givemeanorange/p/5500298.html