O'Reilly logo

Ext JS 4 Web Application Development Cookbook by Stuart Ashworth, Andrew Duncan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating flexible horizontal layouts with HBoxes

The HBox layout allows you to align components horizontally across a container. The screenshot shows three panels horizontally aligned, dividing the available space between them:

Creating flexible horizontal layouts with HBoxes

How to do it...

  1. Start by creating a Viewport:
    Ext.create('Ext.container.Viewport', {});
  2. Define an HBox layout in the Viewport with the following configuration:
    Ext.create('Ext.container.Viewport', {
        layout: {
            type: 'hbox',
            align: 'stretchmax',
            pack: 'center'
        }
    });
  3. Add three panels to the items collection, the first and third with fixed widths, and the second with a flex of 1 to take up the remaining browser space:
    Ext.create('Ext.container.Viewport', ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required