1. #1
    Ext User
    Join Date
    Mar 2007
    Posts
    287
    Vote Rating
    0
    jarrod is on a distinguished road

      0  

    Default GridView fitColumnsToContainer should ignore hidden columns

    GridView fitColumnsToContainer should ignore hidden columns


    Bug as above, probably happens to other similar functions as well.

  2. #2
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    17
    jack.slocum will become famous soon enough jack.slocum will become famous soon enough

      0  

    Default


    I'll go through them. I'll let you know when it's corrected.

  3. #3
    Ext User
    Join Date
    Mar 2007
    Posts
    287
    Vote Rating
    0
    jarrod is on a distinguished road

      0  

    Default


    Additionally, is it possible to add support for fixed width columns?

    Typically, these columns will contain just an icon image or a checkbox and should not be resizable.

  4. #4
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    58
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Yes, good point. I'm going to be adding checkboxes to a lot of my grids. The req's here are to be able to apply operations to groups of entities.

    I suppose I could use regular multi-select, but they like checkboxes.

    Could a custom SelectionModel add a "phantom" column containing a checkbox? I suppose the ColumnModel would have to co-operate with any new CheckboxSelectionModel implementation. I'll think about this.

  5. #5
    Ext User
    Join Date
    Mar 2007
    Posts
    287
    Vote Rating
    0
    jarrod is on a distinguished road

      0  

    Default


    Just wrote a method for the grid, similar to GridView's fitColumnsToContainer().

    It proportionately distributes the excess (or shortage) of width across columns which are neither hidden nor fixed width.

    Code:
        fitColumns : function(){
            var view = this.getView();
            var colModel = this.colModel;
            var colCount = colModel.getColumnCount();
            var wrap = view.wrap;
            var cols = [];
            var width = 0;
            var i, w;
    
            for (i = 0; i < colCount; i++){
                var config = colModel.config[i];
                if (!config.fixed && !config.hidden){
                    w = colModel.getColumnWidth(i);
                    cols.push(i);
                    cols.push(w);
                    width += w;
                }
            }
            var frac = (wrap.clientWidth - colModel.getTotalWidth())/width;
            while (cols.length){
                w = cols.pop();
                i = cols.pop();
                colModel.setColumnWidth(i, Math.floor(w + w*frac), true);
            }
            view.updateColumns();
        }

  6. #6
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    17
    jack.slocum will become famous soon enough jack.slocum will become famous soon enough

      0  

    Default


    Cool Jarrod, thanks. I will add it in. I will have to change the direct config access to method calls to support extended ColumnModels.

  7. #7
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    17
    jack.slocum will become famous soon enough jack.slocum will become famous soon enough

      0  

    Default


    Here's what I ended up adding (I added it to GridView not the grid):

    Code:
    fitColumns : function(){
            var cm = this.grid.colModel;
            var colCount = cm.getColumnCount();
            var cols = [];
            var width = 0;
            var i, w;
            for (i = 0; i < colCount; i++){
                if(!cm.isHidden(i) && !cm.isFixed(i)){
                    w = cm.getColumnWidth(i);
                    cols.push(i);
                    cols.push(w);
                    width += w;
                }
            }
            var frac = (this.wrap.clientWidth - cm.getTotalWidth())/width;
            while (cols.length){
                w = cols.pop();
                i = cols.pop();
                cm.setColumnWidth(i, Math.floor(w + w*frac), true);
            }
            this.updateColumns();
        },
    And:

    Code:
    YAHOO.ext.grid.GridView.prototype.fitColumnsToContainer = 
                                                         YAHOO.ext.grid.GridView.prototype.fitColumns;
    The isFixed method is new in .33 beta 2 and disables adding the splitter. It's probably similar to what you seem to have already.

  8. #8
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    17
    jack.slocum will become famous soon enough jack.slocum will become famous soon enough

      0  

    Default


    To explain a little further:

    There's are two new properties "resizable" and "fixed". resizable is less restrictive.

    resizable simply limits the user from being able to resize to column. fixed limits the user from resizing AND prevents autosizing operations from resizing the column as well.

  9. #9
    Ext User
    Join Date
    Mar 2007
    Posts
    287
    Vote Rating
    0
    jarrod is on a distinguished road

      0  

    Default


    Cool, will switch over to these new features when I get hold of the updated beta 2 build...

    Btw, it maybe useful to have a repository page for downloading interim builds?

Similar Threads

  1. fitColumnstocontainer in Ext 1.0
    By galdaka in forum Ext 2.x: Help & Discussion
    Replies: 6
    Last Post: 5 Oct 2007, 6:41 AM
  2. Why doesn't autoSizeColumns ignore markup when calculating?
    By KRavEN in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 28 Mar 2007, 10:21 AM
  3. GridView bufferRows FF bug?
    By ericwaldheim in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 22 Mar 2007, 8:42 AM
  4. Replies: 2
    Last Post: 20 Dec 2006, 6:48 PM
  5. Prolem with hidden columns
    By anakreon in forum Ext 1.x: Help & Discussion
    Replies: 10
    Last Post: 9 Nov 2006, 7:24 AM

Thread Participants: 2