getValues() 还是 getFieldValues() [转]
Posted 桔子爱世界
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了getValues() 还是 getFieldValues() [转]相关的知识,希望对你有一定的参考价值。
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() [转]的主要内容,如果未能解决你的问题,请参考以下文章
我可以将 Enum 扩展为 Enum.GetValues() 吗? [复制]
卡在 SqlDataReader.GetValues 方法上
如何在 System.Data.IDataReader 中模拟 GetValues() 方法?
应用程序脚本缓慢调用多次调用具有多个范围的相同函数,它调用 getValues
为什么HttpRequestHeaders.GetValues(string)返回的IEnumerable只有1个字符串?
Sencha Touch MVC :: 试图到达 Ext.extend(Ext.form.FormPanel,...) 的 getValues()