DeLe
DeLe

Reputation: 2480

Extjs4.1 - How to make items inheritance layout parent

I define a panel have 2 items look like http://jsfiddle.net/BB8Vu/

Ext.define('Example', {
    extend: 'Ext.panel.Panel',
    border: false,
    alias: 'widget.example',
    items: [{
        fieldLabel: 'Age',
        name: 'age',
        xtype: 'numberfield',
        minValue: 0,
        maxValue: 100
    }, {
        xtype: 'timefield',
        fieldLabel: 'Time',
        name: 'time',
        minValue: '8:00am',
        maxValue: '6:00pm'
    }]
});

And i using that in another form. If that form hasn't layout then that's correct. But if i using layout like

Ext.create('Ext.form.Panel', {
    title: 'Simple Form',
    bodyPadding: 5,
    width: 350,
    url: 'save-form.php',

    layout: 'anchor',
    defaults: {
        anchor: '100%'
    },


    defaultType: 'textfield',
    items: [{
        fieldLabel: 'First Name',
        name: 'first',
        allowBlank: false
    },{
        xtype: 'example'
    }],
    renderTo: Ext.getBody()
});

that's fail look like (width of items in example not inheritance layout parent)

enter image description here

How to make items of example inheritance layout parent. Thanks

Upvotes: 1

Views: 527

Answers (1)

sra
sra

Reputation: 23973

Extend the defaults:

defaults: {
    anchor: '100%',
    layout: 'anchor',
    defaults: {anchor: '100%'}
},

see your updated JSFiddle

Note that a layout config get only processed on a container and not on a component because a component don't has childs

Upvotes: 3

Related Questions