extjs tree下拉列表_Extjs combox Tree 下拉框树点击+隐藏问题

本文解决了ExtJS中ComboBox Tree组件在点击加号后下拉树自动隐藏的问题,通过重载ComboBox的onViewClick方法来实现。同时展示了如何创建一个下拉树并监听点击事件,当点击叶子节点时设置ComboBox的值并隐藏下拉树。
摘要由CSDN通过智能技术生成

问题:单击+会隐藏下拉树问题

解决:重载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 : "",

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);

}}

本文来源于网络:查看 >https://blog.csdn.net/java_lifei/article/details/9049581

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值