Horizontal Scrollbar in GridPanel

  1. #1

    Horizontal Scrollbar in GridPanel

    The horizontal scrollbar in a GridPanel will not be rendered unless you specifically supply a height to the grid panel. This has been fixed in ExtJs 4.2.2 (see EXTJSIV-9204) , which is not a public release and so is not included with Ext.Net

    Do you have any suggestions how this can be overcome without specifying a height, and in addition, you also are not able to determine whether the grid will be larger than the container it's placed in?

    Thanks
  2. #2
    Turns out I was able to put two halves of solutions together to make a reasonable work-around

    On the grid (Razor MVC)
    X().GridPanel()
    ...
    .Listeners(
        l =>
        {
            l.AfterRender.Delay = 1000;
            l.AfterRender.Handler = "SetGridHeight(this);";
        }
                            
    )
    JavaScript Function to Set Height
    function SetGridHeight( grid )
    {
        //check if grid needs a horizontal scrollbar
        if ( grid.view.getWidth() < parseFloat( grid.view.getEl().dom.children[0].style.width ) )
        {
            var iHeight = grid.getHeight();
            grid.setHeight( iHeight + 18 );  //18 being the extra height for the new scrollbar
        }
    }
    Should work in most circumstances in a Fit design. The 1 second delay is necessary as AfterRender will otherwise not provide the currently rendered Height (which seemed very odd) and AfterLayout (which triggers multiple times) creates infinite loops if you try and alter the layout.

Similar Threads

  1. [CLOSED] enable horizontal scrollbar in the gridpanel 2.x
    By farallones in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Oct 23, 2013, 3:51 PM
  2. [CLOSED] Horizontal Scrollbar in GridPanel missing.
    By Z in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Dec 10, 2012, 12:12 PM
  3. Enable Horizontal scrollbar in gridpanel
    By Aswini Ladish in forum 1.x Help
    Replies: 18
    Last Post: Dec 05, 2012, 9:25 AM
  4. [CLOSED] GridPanel Horizontal Scrollbar does not exist
    By tansu in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 28, 2012, 7:11 PM
  5. [CLOSED] GridPanel horizontal scrollbar
    By jeybonnet in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: May 27, 2011, 6:00 AM

Posting Permissions