Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to insert spaces between components in Ext js 4 layout

Tags:

extjs

I'm moving from adobe flex to ext js 4, and I noted that in Extjs, the components are placed too close. There is no gap between then. This can be faced with this example:

    var win = Ext.create('Ext.window.Window', {
    layout: 'hbox',
    height: 500,
    width: 400,
    title: 'hbox',      
    items: [
      Ext.create('Ext.button.Button',
      {
        text: 'My button 1',
        width: 150
      }),
      Ext.create('Ext.button.Button',
      {
        text: 'My button 2',
        width: 150
      })
    ]
});

win.show();

The two button are zero space from each other.

How to set a space (gap or ever) from components?

Thanks.

like image 559
Beetlejuice Avatar asked Jul 03 '12 12:07

Beetlejuice


2 Answers

Use the margin config:

Ext.onReady(function() {
    var win = Ext.create('Ext.window.Window', {
        layout: 'hbox',
        height: 500,
        width: 400,
        autoShow: true,
        title: 'hbox',
        defaultType: 'button',
        items: [{
            text: 'My button 1',
            width: 150,
            margin: '10 20 30 40'
        }, {
            text: 'My button 2',
            width: 150,
            margin: '40 30 20 10'
        }]
    });
});
like image 139
Evan Trimboli Avatar answered Nov 04 '22 07:11

Evan Trimboli


like a margin ? You can add that by the style atttribute. See this ex http://jsfiddle.net/nscrob/5rn8C/5/

like image 40
nscrob Avatar answered Nov 04 '22 07:11

nscrob