1. #1
    Sencha User
    Join Date
    Aug 2012
    Posts
    4
    Vote Rating
    0
    direct2kali is on a distinguished road

      0  

    Default Unanswered: Grouped Header Column size

    Unanswered: Grouped Header Column size


    I have a grid with grouped header. The definition can be found here. http://jsfiddle.net/7sZge/

    The result looks like this.

    notworkinggrid.jpg

    I want all the columns including the columns inside the grouped header to be evenly spaced out. What am I missing here?

  2. #2
    Sencha - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,333
    Answers
    124
    Vote Rating
    85
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      0  

    Default


    Hi direct2kali,
    Try this:
    http://dev.sencha.com/deploy/ext-4.0.7-gpl/examples/grid/group-header-grid.html
    • Also you can provide equal width to your each column of grid instead of flex.
    • You may specify inner headers width in accordance to their parent header.
    Last edited by sword-it; 13 Sep 2012 at 2:26 AM. Reason: formatting
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  3. #3
    Sencha User
    Join Date
    Aug 2012
    Posts
    4
    Vote Rating
    0
    direct2kali is on a distinguished road

      0  

    Default


    hi sword,
    thanks for your reply.

    But I want to display my grid columns to cover the entire width available. So, I went with flex. I have tried with normal grids similarly and it's working fine. The problem comes only for grids with grouped header.

    Is there any way I can display the entire grid for the possible available width and also make all the columns evenly spaced?

  4. #4
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,927
    Answers
    656
    Vote Rating
    443
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    This is not available with grouping headers at this time.

    Scott.

  5. #5
    Sencha Premium Member
    Join Date
    Nov 2011
    Posts
    72
    Answers
    6
    Vote Rating
    13
    eric.cook will become famous soon enough

      1  

    Default Temporary Solution

    Temporary Solution


    Hey there, I posted a response to this on your StackOverflow question. Found that override code I mentioned, but I thought I'd post it here where it would get more visibility. This is my solution to the grouped flex column problem for 4.1.0. It only supports two levels of headers and is definitely not the best solution, but it seems to get the job done.

    Basically, every column starts with a flex and the layout method converts everything into widths. Once everything is a width, it should follow the normal rules for resizing/hiding/showing. I have no idea if it works with unsealed columns, but it theoretically should.

    It uses a couple special properties. First, I added an "isRowExpander" property to the column added by the Ext.ux.RowExpander plugin to identify it as a special case. Second, it uses the "forceFit" property as a flag to run the calculations (might as well use it for something, I suppose). Lastly, I've had some problems with the finished width running a few pixels over the total width in the case of certain flex/totalFlex ratios not being nice numbers. I noted where I think the problem occurs.

    Code:
    Ext.override(Ext.grid.ColumnLayout, {
        completeLayout: function(ownerContext){
            var me = this,
                owner = me.owner,
                state = ownerContext.state,
                needsInvalidate = false,
                calculated = me.sizeModels.calculated,
                configured = me.sizeModels.configured,
                totalFlex = 0, totalWidth = 0, remainingWidth = 0, colWidth = 0,
                childItems, len, i, childContext, item,
                j, sublen, subChild;
    
    
            me.callParent(arguments);
    
    
            // Get the layout context of the main container
            // Required two passes. First pass calculates total flexes of all items
            // and child items. Second pass uses those flex values to calculate fixed
            // widths for each item, then removes flexing so resizing/hiding works.
            if(!state.flexesCalculated && owner.forceFit && !owner.isHeader){
                childItems = ownerContext.flexedItems = ownerContext.childItems;
                len = childItems.length;
                totalWidth = state.contentWidth;
                if(state.contentWidth < state.boxPlan.availableSpace){
                    totalWidth += state.boxPlan.availableSpace - 2;
                }
                remainingWidth = totalWidth;
    
    
                // Begin first pass
                ownerContext.flex = 0;
                for(i = 0; i < len; i++){
                    childContext = childItems[i];
                    item = childContext.target;
                    // Special code for Ext.ux.RowExpander
                    if(item.isRowExpander){
                        item.width = item.flex || item.width;
                        totalWidth -= item.width;
                        remainingWidth -= item.width;
                        item.forceFit = false;
                        delete item.flex;
                        continue;
                    }
    
    
                    if(item.isGroupHeader){
                        totalFlex = 0;
                        for(j = 0, sublen = childContext.childItems.length; j < sublen; j++){
                            subChild = childContext.childItems[j];
                            subChild.widthModel = calculated;
                            totalFlex += subChild.flex;
                        }
                        item.flex = childContext.flex = childContext.totalFlex = totalFlex;
                        ownerContext.flex += totalFlex;
                        needsInvalidate = true;
                    }
                    else{
                        ownerContext.flex += item.flex;
                    }
                }
    
    
                ownerContext.totalFlex = ownerContext.flex;
    
    
                // Begin second pass
                for(i = 0; i < len; i++){
                    childContext = childItems[i];
                    item = childContext.target;
    
    
                    if(item.isRowExpander){
                        continue;
                    }
    
                    // This is probably where the overflow is happening
                    // Might try using Math.round or Math.floor instead of Math.ceil
                    item.width = colWidth = Math.min(Math.ceil((totalWidth / ownerContext.totalFlex) * childContext.flex), remainingWidth);
                    remainingWidth -= colWidth;
                    childContext.sizeModel.width = childContext.widthModel = configured;
    
    
                    if(item.isGroupHeader){
                        for(j = 0, sublen = childContext.childItems.length; j < sublen; j++){
                            subChild = childContext.childItems[j];
                            // Another use of Math.ceil where Math.round might work better
                            subChild.target.width = Math.ceil((item.width / childContext.flex) * subChild.flex);
                            subChild.sizeModel.width = subChild.widthModel = configured;
                            delete subChild.flex;
                            delete subChild.target.flex;
                        }
                        childContext.sizeModel.width = childContext.widthModel = calculated;
                        delete item.width;
                        delete item.flex;
                    }
                    
                    item.forceFit = false;
                }
    
    
                delete owner.flex;
                owner.forceFit = false;
    
    
                if(needsInvalidate){
                    ownerContext.invalidate({state: {flexesCalculated: true}});
                }
            }
        }
    });
    This needs to be a feature of Ext JS grids. I know the dev team has a lot on their hands with bug reports and other features but this seems like a crucial piece of functionality that many user projects would depend on (like mine did). Anyway, I hope this code helps out in the meantime.

  6. #6
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,927
    Answers
    656
    Vote Rating
    443
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    Interesting .. thanks for the post.

    Scott.

  7. #7
    Sencha User
    Join Date
    Oct 2012
    Posts
    1
    Vote Rating
    0
    Phil.W is on a distinguished road

      0  

    Default


    Hi,

    I successfully used your workaround for grouped headers.
    Good job.

    However, because of issues I had with Ext JS V4.1.0, I had to migrate to version 4.1.1 and unfortunately, your workaround doesn't seem to be compatible with that version.
    I get an exception thrown in cacheFlexes(Ext.layout.container.Box)
    I was wondering if you had experienced the same issue and maybe knew how to fix it

    Cheers,

    Phil

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi