1. #1
    Ext User
    Join Date
    Nov 2009
    Posts
    4
    Vote Rating
    0
    kotovsky is on a distinguished road

      0  

    Default TreeGrid columns fit

    TreeGrid columns fit


    How can I make the columns fit in tree grid? such as in GridPanel viewConfig: {forceFit: true} ?

  2. #2
    Sencha User Eugen_'s Avatar
    Join Date
    Feb 2010
    Posts
    106
    Vote Rating
    -5
    Eugen_ is infamous around these parts

      1  

    Default


    Quote Originally Posted by kotovsky View Post
    How can I make the columns fit in tree grid? such as in GridPanel viewConfig: {forceFit: true} ?
    Change the TreeGrid and Ext.tree.ColumnResizer source code

    Code:
    Ext.ux.tree.TreeGrid = Ext.extend(Ext.tree.TreePanel, {
    
        ...
    
        fitColumns: function() {
            var nNewTotalWidth = this.getInnerWidth() - Ext.num(this.scrollOffset, Ext.getScrollBarWidth());
            var nOldTotalWidth = this.getTotalColumnWidth();
            var cs = this.getVisibleColumns();
            var n, nUsed = 0;
            
            for (n = 0; n < cs.length; n++) {
                if (n == cs.length - 1) {
                    cs[n].width = nNewTotalWidth - nUsed - 1;
                    break;
                }
                cs[n].width = Math.floor((nNewTotalWidth / 100) * (cs[n].width * 100 / nOldTotalWidth)) - 1;
                nUsed += cs[n].width;
            }
            
            this.updateColumnWidths();
        },
        
        ...
        
        onResize : function(w, h) {
    
            ...
            
            this.fitColumns();
        },
    
        ...
    
    });
    Code:
    Ext.tree.ColumnResizer = Ext.extend(Ext.util.Observable, {
    
        ...
    
        onEnd : function(e){
    
            ...
        
            //tree.updateColumnWidths();
            tree.fitColumns();
    
        }
    });

Thread Participants: 1