【ExtJS】 FormPanel与ComboBox的集成以及值的获取

var formPanel = Ext.create("Ext.form.Panel",{

  title : ‘formPanel‘,

  width : 400,

  url : ‘asd.php‘    //默认通过Ajax提交到这个url

  layout : ‘anchor‘,  //布局占满整个宽度

  defaults : {

    anchor : ‘100%‘  

  },

  items :[{

    xtype : ‘textfield‘,  //文本编辑

    fieldLabel : ‘FirstName‘,

    name : ‘first‘,

    allowBlank : ‘true‘  

  },{

    xtype : ‘combo‘,  //comboBox

    id : ‘cmbId‘,

    fieldLabel : ‘cmbName‘,

    store : new Ext.data.SimpleStore({

      fields : [‘value‘,‘text‘],

      data : [

         [1, ‘name1‘], [2, ‘name2‘], [3,‘name3‘], ...

      ]

    }),

    queryMode : ‘local‘,

    displayField : ‘text‘,

    valueField : ‘value‘,

    renderTo : Ext.getBody()

  }],

  buttons : [{

          text : ‘reset‘,

          handler : function(){

            this.up(‘form‘).getForm().reset();

          }

        },{

           text : ‘save‘,

           handler : function(){

             var textValues =this.getValues()[‘first‘];  //  获取编辑框的值,根据‘name’

             var cmbValues = Ext.getCmp(‘cmbId‘).getValue();      //  获取comboBox的值,根据‘id’

               ...

            } 

        }]

});

  1、关于获取FormPanel内各个组件的值,this.getValues()获取form中所有表单域当前值得 快捷函数. 和调用this.getForm().getValues()返回的结果是一样的.

  2、对于get()、getDom()、getCmp()、getBody()、getDoc()的区别:

  get(id/obj):

    get方法用来得到一个Ext元素,也就是类型为Ext.Element的对象, Ext.Element类是Ext对DOM的封装,代表DOM的元素,可以为每一个DOM创建一个对应的Element对象,可以通过Element对象 上的方法来实现对DOM指定的操作,比如用hide方法可以隐藏元素、initDD方法可以让指定的DOM具有拖放特性等。get方法其实是Ext.Element.get的简写形式。get方法中只有一个参数,这个参数是混合参数,可以是DOM节点的id、也可以是一个Element、或者是一个DOM节点对象等。

  getDom(id/obj):

    getDom方法能够得到文档中的DOM节点,该方法中包含一个参数,该参数可以是DOM节点的id、DOM节点对象或DOM节点对应的Ext元素(Element)等。

  

  getCmp(id):

    getCmp方法用来获得一个Ext组件,getCmp方法中只有一个参数,也就是组件的id。

  getBody():

    得到文档的body节点元素(Element)。

    

  getDoc():

    获得与document对应的Ext元素(Element),getDoc方法实质上就是得到当前html文档对象,也就是把document对象封装成ExtJS的Element对象返回。

时间: 2024-08-10 15:55:11

【ExtJS】 FormPanel与ComboBox的集成以及值的获取的相关文章

ExtJs FormPanel布局

FormPanel有两种布局:form和column,form是纵向布局,column为横向布局.默认为后者.使用layout属性定义布局类型.对于一个复杂的布局表单,最重要的是正确分割,分割结果直接决定布局能否顺利实现.如果不再使用默认布局,那么我们必须为每一个元素指定一种布局方式,另外,还必须遵循以下几点:[1]落实到任何一个表单组件后,最后总是form布局[2]defaultType属性不一定起作用,必须显式为每一个表单组件指定xtype或new出新对象[3]在column布局中,通过co

非映射的形式检查TextBox,ComboBox控件的值是否为空(是否被选中)

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Med

c#(winform)中ComboBox添加Key/Value项、获取选中项、根据Key

WinForm下的ComboBox默认是以多行文本来设定显示列表的, 这通常不符合大家日常的应用, 因为大家日常应用通常是键/值对的形式去绑定它的. 参考了一些网上的例子,最终写了一个辅助类用于方便对ComboBox的操作: 用下面这个类的实例作为ComboBox的添加项: using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; namespace tp7309.

easyui-textbox 和 easyui-validatebox 设置值和获取值

表单作如下定义:该input使用easyui的"easyui-textbox" 1 <input id="addSnumber" style="width: 200px; height: 30px;" class="easyui-textbox" type="text" name="snumber" data-options="required:true, missing

基于ANDROID平台,U3D对蓝牙手柄键值的获取

对于ANDROID平台,物理蓝牙手柄已被封装,上层应用不可见,也就是说对于上层应用,不区分蓝牙手柄还是其它手柄: 完成蓝牙手柄和ANDROID手机的蓝牙连接后,即可以UNITY3D中获取其键值: 在U3D中已有对手柄键值的获取接口,主要分两类: 1.摇杆: translationy = Input.GetAxis("Vertical") * 10.0f; translationx = Input.GetAxis("Horizontal") * 10.0f; Inpu

向值栈获取List集合

-------------------siwuxie095 从值栈获取 List 集合 1.具体步骤 (1)在 Action 中向值栈放 List 集合 (2)在 JSP 页面中从值栈获取 List 集合 2.具体实现 (1)编写实体类 User.java: package com.siwuxie095.entity; // User 实体类 public class User { private String username; private String password; private

从值栈获取对象

-------------------siwuxie095 从值栈获取对象 1.具体步骤 (1)在 Action 中向值栈放对象 (2)在 JSP 页面中从值栈获取对象 2.具体实现 (1)编写实体类 User.java: package com.siwuxie095.entity; // User 实体类 public class User { private String username; private String password; private String address; p

从值栈获取数据

--------------------siwuxie095 从值栈获取数据 1.使用 Struts2 标签 + OGNL 表达式 获取值栈数据 主要:<s:property value="OGNL 表达式"/> 2.具体步骤 (1)在 Action 中向值栈放数据 (2)从 JSP 页面中获取值栈数据 3.具体实现 (1)编写 Action DataAction.java: package com.siwuxie095.action; import com.opensym

easyUI validatebox设置值和获取值,以及属性和方法

一:表单元素使用easyui时,textbox和validatebox设置值和获取值的方式不一样[转] 1.为text-box设置值只能使用id选择器选择表单元素,只能使用textbox("setValue", value) 方式设置值,使用textbox("getValue")  获取值: 例如:var snumber = $("#addSnumber").textbox('getValue'); $("#addSnumber&quo