使用combobox時,它有一個hiddenName的屬性,專門用於提交combobox中value的值.
現假設某combobox的Id為comboId,hiddenName屬性的值為hiddenValue,
那么,
使用Ext.get('comboId').dom.value方法獲取的是combobox中選中項的文本text值,
Ext.getCmp("ID值").getValue();獲取到的是Value值
.replace(/\s/g, ""); //移除json文本中所有的換行,空格,制表符;
=========================================
extjs 執行button的點擊事件,執行handler事件
最簡單的方法是查看extjs生成后的html代碼dom里面 找到對應的生成的ID的
例如:
方法1:var btn = document.getElementById("ext-gen40");//這里的ext-gen40就是extjs 隨即生成的iD 但是有時候這個id會變化的,
btn.click();
方法2:Ext.getCmp('title2d').fireEvent("click"); //這里的 ”title2d“ 是extjs代碼中的id
執行按鈕handler事件:
var btn2d = Ext.getCmp("title2d");
btn2d.handler.call(btn2d.scope, btn2d);
onClick是一個方法,而handler是一個配置項
extjs onclick和handler的區別:http://blog.csdn.net/21aspnet/article/details/6865571
======================================================獲取文本框的值
1、Html文本框
如:<input type="text" name="test" id="test" >
獲取值的方式為:
var tValue = Ext.getDom('test').value;
或者
var tValue = document.getElementById('test').value
2、ExtJs的組件
如:{
id:'test',
xtype:'textfield',
fieldLabel:' 測試',
name:'test',
width:370
}
獲取值的方式為:
var tValue = Ext.getCmp('test').getValue();
Ext.get('test').dom.value
設置文本框的值
Ext.getCmp('test').setValue("設置的值");
==============================按鈕的 啟用 和 禁用
Ext.getCmp('btnQc').disable();//禁用
Ext.getCmp('btnQc').enable();//啟用
方法1:可以在定義bbar的按鈕時直接給屬性,hidden : true 屬性,可隱藏;disabled : true 屬性,可禁用
方法2:給按鈕添加id,比如id:'btn';然后在panel的事件中調用Ext.getCmp('btn').disable();禁用或Ext.getCmp('btn').enable();開啟。Ext.getCmp('btn').setVisible (false);隱藏或Ext.getCmp('btn').setVisible (true);顯示。
Combobox本地模糊查詢:
{ type : 'combobox',//加上類型 fieldLabel : '企業名稱', name : 'projectManagerId', allowBlank : false, anchor : '90%', store : StoreID, valueField : 'EntCode', displayField : 'EntName', typeAhead : true, triggerAction : 'all', mode: 'local',//聲明此屬性即可實現過濾,前提你的editable屬性一定是false
//editable:false, lazyRender : true }
效果如下:
輸入關鍵字查詢:
ExtJs給Combobox賦值
Ext.getCmp('qd_shiyou').setValue(id);
Ext.getCmp('qd_shiyou').setRawValue(name);