问题:单击+会隐藏下拉树问题
解决:重载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