Extjs combox Tree 下拉框樹點擊+隱藏問題

問題:單擊+會隱藏下拉樹問題

解決:重載ComboBox

Ext.override(Ext.form.ComboBox, { 
onViewClick : function(doFocus) { 
var index = this.view.getSelectedIndexes()[0], s = this.store, r = s.getAt(index);
if (r) { 
this.onSelect(r, index); 
} else if (s.getCount() === 0) { 
this.collapse(); 

if (doFocus !== false) { 
this.el.focus(); 


});


/**

*下拉樹展示

*/

function createComboxTree(comboxId) {

var comboxWithTree = new Ext.form.ComboBox( {
store : new Ext.data.SimpleStore( {
fields : [ 'id', 'name' ],
data : [ [] ]
}),
editable : false,
mode : 'local',
triggerAction : 'all',
fieldLabel : '用戶分組',
emptyText : '請選擇分組',
width : 200,
allowBlank : false,
blankText : '用戶分組不能不爲空',
displayField : 'name',
id : comboxId,
hiddenName : 'groupName',
valueField : 'id',
tpl : "<tpl for='.'><div style='height:220px'><div id='"
+ comboxId + "tree2'></div></div></tpl>",
selectedClass : '',
onSelect : Ext.emptyFn
});
var root = new Ext.tree.AsyncTreeNode( {
text : '分組樹',
draggable : false,
id : 'ROOT',
expanded : true,
loader : new Ext.tree.TreeLoader( {
dataUrl : REQUEST_URL_BASE
+ "rdpUserInfoHandler/getGroupForTreeByCurrentUser"
})
});
var comboxTree = new Ext.tree.TreePanel( {
id : 'comboxGroupTree',
animate : false,
split : true,
singleExpand : true,
lines : false,
autoScroll : true,
root : root,
width : 200,
height : 500
});
comboxTree.on('click', function(node) {

if(node.leaf){
comboxWithTree.setValue(node.attributes.text);
Ext.getCmp("groupIds").setValue(node.attributes.id);
Ext.getCmp("groupIdsAdd").setValue(node.attributes.id);
Ext.getCmp("groupIdSearch").setValue(node.attributes.id);
comboxWithTree.collapse();//隱藏樹列表

}else{

node.toggle();

}
}, this, {
stopEvent : true
});
comboxTree.on('expandnode', function(node) {
}, this, {
stopEvent : true
});
comboxWithTree.on('expand', function() {
comboxTree.render(comboxId + 'tree2');
});

return comboxWithTree;
}



//dataGrid前面的每行的選中  去掉標題上的全選效果

this.sm=new Ext.grid.CheckboxSelectionModel({
        listeners:{
        'rowdeselect': function(s){
            if(s.getCount( )!= this.grid.getStore().getCount()){
               //通過sm得到已選的行的總數,和表中這一頁的行數做比較,如果不相等表示還有爲選項,則通過下面代碼將標題欄的勾選狀態去掉。
                var hd_checker = this.grid.getEl().select('div.x-grid3-hd-checker');
                var hd = hd_checker.first();
                if(hd != null){ 
                    hd.addClass('x-grid3-hd-checker-on');
                    hd.removeClass('x-grid3-hd-checker-on'); //這個是去掉上面標題中的
                }
            }    
        }
        }
     });



在textField 後面加上提示信息

listeners : {render : function(obj){
                             var font = document.createElement(font);
                             font.setAttribute("color","red");
                             font.appendChild(document.createTextNode('應用名稱,將作爲應用標題,如[數據監控管理平臺]'));
                             obj.el.dom.parentNode.appendChild(font);
                  }}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章