Struts2+Spring2.5+Hibernate3(JPA)+ExtJS3基本后台 将ExtJS替换为3..2版本后发现下拉数有些异常:之前展开下来树的下级节点时,下拉菜单不会关掉。但是在3.2版本中无论你在弹出的选择框中点击任何部分,包括选中节点、点击空白处以及点击展开下级节点,弹出框都会自动关闭。查看源代码发现有一部分代码的修改比较困惑:
3.1版本中Combo.js的部分代码
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.onEmptyResults(); } if(doFocus !== false){ this.el.focus(); } }, onEmptyResults : function(){ this.collapse(); },
3.2版本中Combo.js的部分代码
onViewClick : function(doFocus){ var index = this.view.getSelectedIndexes()[0], s = this.store, r = s.getAt(index); if(r){ this.onSelect(r, index); }else { this.collapse(); } if(doFocus !== false){ this.el.focus(); } },
相比之下这里没有进行if(s.getCount() === 0)的比较,貌似这个是判断store是否存在记录的。个人感觉这应该是3.2的一个Bug。因此修改ExtJS3 下拉树TreeComboBox的修改 在代码中增加
// 修复ExtJS3.2中自动关闭下来树的Bug
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();
}
}
});