zoukankan      html  css  js  c++  java
  • 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;    
                     },
    
  • 相关阅读:
    C语言 两个跟结构(struct)有关的参数传递问题
    Linux虚拟机 Ubuntu执行sudo apt-get install出现无法解析域名
    损失函数
    决策树(分类树、回归树)
    k近邻(k-NN)算法
    机器学习和深度学习的区别
    无量纲量和有量纲量
    常用激活函数/损失函数/代价函数
    深度学习:激活函数、损失函数、优化函数的区别
    逻辑回归--推导明确,但理论较少
  • 原文地址:https://www.cnblogs.com/givemeanorange/p/5500298.html
Copyright © 2011-2022 走看看