`

ExtJs 中的TreeGrid(Ext.ux.maximgb.tg.EditorGridPanel详解与其他问题解决办法)2

EXT 
阅读更多
Ext.ux.maximgb.tg.EditorGridPanel


所形成的树形表格,如果当右侧数据更改后,会出现节点位置偏(左)移,这要怎么解决了,

解决方法:

   在引入的js文件TreeGrid.js中,只要重写这些方法即可:

 

    onAdd : function(ds, records, index)
    {
        Ext.ux.maximgb.tg.GridView.superclass.onAdd.call(this, ds, records, index);
        if (this.mainWrap) {
           //this.updateAllColumnWidths();
           this.processRows(0);
        }
    },
    
    onRemove : function(ds, record, index, isUpdate)
    {
        Ext.ux.maximgb.tg.GridView.superclass.onRemove.call(this, ds, record, index, isUpdate);
        if(isUpdate !== true){
            if (this.mainWrap) {
                //this.updateAllColumnWidths();
                this.processRows(0);
            }
        }
    },
    
    onUpdate : function(ds, record)
    {
        Ext.ux.maximgb.tg.GridView.superclass.onUpdate.call(this, ds, record);
        if (this.mainWrap) {
            //this.updateAllColumnWidths();
            this.processRows(0);
        }
    },

  在每个方法中加入以下代码即可:

this.grid.view.refresh();

 

 重写后为:

 onAdd : function(ds, records, index)
    {
        Ext.ux.maximgb.tg.GridView.superclass.onAdd.call(this, ds, records, index);
        if (this.mainWrap) {
           //this.updateAllColumnWidths();
           this.processRows(0);
           //  add 
           this.grid.view.refresh();
         }
    },
    
    onRemove : function(ds, record, index, isUpdate)
    {
        Ext.ux.maximgb.tg.GridView.superclass.onRemove.call(this, ds, record, index, isUpdate);
        if(isUpdate !== true){
            if (this.mainWrap) {
                //this.updateAllColumnWidths();
                this.processRows(0);
           		//  add 
          		 this.grid.view.refresh();
            }
        }
    },
    
    onUpdate : function(ds, record)
    {
        Ext.ux.maximgb.tg.GridView.superclass.onUpdate.call(this, ds, record);
        if (this.mainWrap) {
            //this.updateAllColumnWidths();
            this.processRows(0);
           //  add 
           this.grid.view.refresh();            
        }
    },
 

   即在添加、删除、更改后,刷新一遍即可!

 

   另外在Grid中有时候会统计所有子节点的值进行汇总时,store中只有query()方法,但有时会有问题,出现统计子节点出现计算错误:

 var mixedCollection=s.queryExact("_parent",record.get("_id"));

 这个时候就要重写store中原的的方法query了:

    store中原有方法query为:

    query : function(property, value, anyMatch, caseSensitive){
        var fn = this.createFilterFn(property, value, anyMatch, caseSensitive);
        return fn ? this.queryBy(fn) : this.data.clone();
    },

  重写query方法,改名后(queryExact --自定义)为:

Ext.override(Ext.data.Store,{
    
    queryExact : function(property, value, anyMatch, caseSensitive){
        var fn = this.createFilterFn(property, value, anyMatch, caseSensitive, true);
        return fn ? this.queryBy(fn) : this.data.clone();
    }
});
 

 

 

 

  • 大小: 5.4 KB
分享到:
评论
7 楼 wokao_wg 2013-11-20  
大伙可以看看作者说的
http://www.sencha.com/forum/showthread.php?76331-TreeGrid-(Ext.ux.maximgb.tg)-a-tree-grid-component-based-on-Ext-s-native-grid.
很有用
6 楼 tlp080931 2013-10-12  
你好!朋友,求demo,1063865233@qq.com,谢谢!
5 楼 seveny 2013-07-11  
求demo,谢谢,weiyan87811@126.com
4 楼 wancaihua 2013-05-05  
求DEMO,83636306@qq.com,多谢!
3 楼 Inspiration 2012-02-02  
能不能给我发一个DEMO
chengxiangwu@sohu.com
2 楼 008zlj 2011-11-05  
谢谢你哈!!!
1 楼 008zlj 2011-11-05  
请问有treegrid的demo吗?
008zlj@163.com

相关推荐

Global site tag (gtag.js) - Google Analytics