
使用combobox時,它有一個hiddenName的屬性,專門用于提交combobox中value的值.
現假設某combobox的Id為comboId,hiddenName屬性的值為hiddenValue,
那么,使用Ext.get('comboId').dom.value方法獲取的是combobox中選中項的文本text值,
而使用Ext.get('hiddenValue').dom.value獲取的才是combobox中需要提交的value的值。
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);
參考網址:http://www.sencha.com/forum/showthread.php?25677-2.0.1-fireEvent%28-click-%29-on-buttons-don-t-call-handler-function
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);顯示。