ExtJS 3.2 下拉树

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

 

 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值