ee3a84w
Thursday, January 8, 2009

[SOLVED] 3 Column Layout with independent scrollbars for each column?

  • I am in thought trying to accomplish something very simple. Setup a 3-column layout where each column will expand to the height of the container (autoHeight: true,) and have each column have its own independent scrollbar. I have found this nearly impossible to do.

    A simple example of my code is here:

    new Ext.Panel({
    items: [{
    autoHeight: true,
    autoScroll: true,
    columnWidth: .3,
    html: 'column 1'
    }, {
    autoHeight: true,
    autoScroll: true,
    columnWidth: .3,
    html: 'column 2'
    }, {
    autoHeight: true,
    autoScroll: true,
    columnWidth: .4,
    html: 'column 3'
    }],
    layout: 'column'
    });I have tried adding autoScroll: true to the parent panel container but it makes the entire container scroll instead of giving the columns scrollbars. I can't have it this way because I will have a list that will be very long in column 1 and when they look at the bottom of that list they will need to see the top of column 2 without scrolling back up and loosing focus of the bottom of column 1.

    I have also tried layout: 'table' but could not get the contents aligned to the top of the container nor get scrollbars to appear.

    I have read pretty much every thread that had to do with scrollbars and panels and no solution has worked yet so far.

    Any ideas on how to get this done?


  • You can achieve it if you set height of columns:


    Ext.onReady(function() {
    var p = new Ext.Panel({
    items: [{
    autoScroll: true,
    height:172,
    columnWidth: .33,
    html: 'long text here'
    }, {
    autoScroll: true,
    height:172,
    columnWidth: .33,
    html: 'long text here'
    }, {
    autoScroll: true,
    height:172,
    columnWidth: .33,
    html: 'long text here'
    }],
    layout: 'column',
    height: 200,
    width:500,
    title:'Scrolling columns',
    renderTo:document.body

    });


  • I was able to do it by attaching a listener to the parent container which listened for the bodyresize event. Upon re-sizing it would calculate the parent containers height (minus the top & bottom toolbar i am using) and set each column to that height as well.

    listeners: {
    'bodyresize' : {
    fn: function( c ) {
    Ext.getCmp("column1").setHeight( c.getSize().height - c.getTopToolbar().getSize().height - c.getBottomToolbar().getSize().height );
    Ext.getCmp("column2").setHeight( c.getSize().height - c.getTopToolbar().getSize().height - c.getBottomToolbar().getSize().height );
    Ext.getCmp("column3").setHeight( c.getSize().height - c.getTopToolbar().getSize().height - c.getBottomToolbar().getSize().height );
    },
    scope: this
    }
    }Thanks jsakalos for the input. I knew that was normally how HTML worked, I had just thought EXT would by default overcome this for me already. I figured why by default would you not want scrollbars to appear (using autoScroll: true) is you had columns that had inner content that overflowed the content size. Mostly I was expecting it to act the way border layout expand to the container and manage scrollbars. Might be something useful to add in (maybe better implemented than what I did).


  • Setup a 3-column layout where each column will expand to the height of the container (autoHeight: true) and have each column have its own independent scrollbar.

    I need it to expand to the container and so specifying a height attribute would cause it not to fill its parent container's height.


  • Found a better way to do it..

    Ext.getCmp("parent").items.each( function( item , index , length ) {
    item.setHeight( c.getSize().height - c.getTopToolbar().getSize().height - c.getBottomToolbar().getSize().height );
    }, this);


  • Yeah I've read it, but it's impossible w/o coding and with config only. You could set autoHeight:true and then monitor the actual height of columns in a code. When it would reach the container height you would set fixed height on that columns.

    It's just as it works: column divs have no height set so they expand/contract depending on their content. Column layout container has overflow:hidden so if a column is higher it's clipped at container height.

    If you set overflow:auto (autoScroll:true) on columns and don't limit their heights they just expand/contract as before ignoring the container height.

    It is not a limitation of Ext, it's how html works.







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about [SOLVED] 3 Column Layout with independent scrollbars for each column? , Please add it free.