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

Docking items to panels' edges

This recipe demonstrates how to dock items to the edges of a panel. We will show this by adding a toolbar to a panel's edges.

How to do it...

  1. Create a panel and render it to the document's body:
    Ext.create('Ext.panel.Panel', {
        title: 'Panel Header',
        width: 500,
        height: 200,
        bodyPadding: 10,
        html: 'Panel Content',
        renderTo: Ext.getBody(),
        style: 'margin: 50px'
    });
  2. Dock a toolbar to the top of the panel:
    Ext.create('Ext.panel.Panel', {
        title: 'Panel Header',
        width: 500,
        height: 200,
        bodyPadding: 10,
        html: 'Panel Content',
        dockedItems: [{
            xtype: 'toolbar',
            dock: 'top',
            items: [{
                xtype: 'button',
                text: 'Click me'
            }, '->', 'Docked toolbar at the top']
        }],
        renderTo: Ext.getBody(),
        style: 'margin: 50px'
    });

    Tip

    When creating a ...

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