Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

problem with extjs fields layout

Tags:

layout

extjs4

i have the problem with displaying fields on form

var test = Ext.create('Ext.form.Panel', {
        renderTo: 'test',
        title: '1. zzzz',
        width: 800,
        bodyPadding: 5,


        defaults: {
            anchor: '100%'
        },
        items: [
        {
            xtype: 'fieldset',
            defaults: {
                anchor: '100%'
            },
            layout: 'column',
            items: [
            {
                xtype: 'panel',
                fieldDefaults: {
                    msgTarget: 'side',
                    labelWidth: 75

                },
                columnWidth: .5,
                flex: 1,
                defaultType: 'textfield',
                defaults: {
                    anchor: '100%',
                    flex: 1
                },
                items: [
                {
                    xtype: 'numberfield',
                    hideTrigger: true,
                    fieldLabel: 'zzzz',
                    //anchor: '100%',
                    //anchor: '-5',
                    name: 'SRD_NUMBER'
                },
                {
                    fieldLabel: 'zzzz',
                    //anchor: '-5',
                    name: 'SRD_NAME_BR'
                },
                {
                    fieldLabel: 'zzzzz',
                    //anchor: '-5',
                    name: 'SRD_NAME_FL'
                },
                {
                    xtype: 'numberfield',
                    hideTrigger: true,
                    fieldLabel: 'zzzz',
                    disabled: true,
                    //anchor: '-5',
                    name: 'SRD_FOP'
                },
                {
                    fieldLabel: 'zzzz',
                    //anchor: '-5',
                    name: 'SRD_NAME_ORDER'
                },
                {
                    xtype: 'panel',
                    id: 'dep-img',
                    border: false,
                    height: 50,
                    width: 100,
                    cls: 'x-form-item',
                    html: '<img src="http://dep-image/id/10000001482" width="100" height="50" title="zzz">'
                },
                {
                    xtype: 'filefield',
                    name: 'file1',
                    msgTarget: 'side',
                    border: 3,
                    //anchor: '100%',
                    fieldLabel: 'zzzz',
                    buttonText: 'zzzzzz'
                },
                {
                    fieldLabel: 'zzz',
                    //anchor: '-5',
                    name: 'company'
                },
                {
                    fieldLabel: 'zzzz',
                    //anchor: '-5',
                    name: 'company'
                }]
            }
            ]
        } //fieldset
        ]//glob

    });

i need to fit fields width to column width.

on this page http://docs.sencha.com/ext-js/4-0/#/api/Ext.form.FieldContainer 2 examples and in second example they set defaults {layout: '100%'} and it looks like it does not work.

found own salvation: by adding layout: 'fit' or layout: 'anchor' to fieldset anchor defaults: { layout: 'fit', flex: 1 },

thanks to all

like image 540
Subdigger Avatar asked Jul 13 '11 12:07

Subdigger


3 Answers

You must set height property to your form and if it still is not displaying then give height to fieldset too.

like image 195
Zango Avatar answered Oct 11 '22 18:10

Zango


found own salvation: by adding layout: 'fit' or layout: 'anchor' to fieldset anchor

defaults: {
   layout: 'fit',
   flex: 1
},

thanks to all

like image 23
Subdigger Avatar answered Oct 11 '22 19:10

Subdigger


I would specify layout:'fit' on the formPanel since you are using a single fieldset.

The rest i dont understand. It looks like you specify column layout but using just one column.

Could you clean up the example and i would be happy to help.

like image 32
Fredric Berling Avatar answered Oct 11 '22 19:10

Fredric Berling