1. #1
    Sencha Premium Member
    Join Date
    Mar 2012
    Location
    Norway
    Posts
    24
    Vote Rating
    0
    atomcat is on a distinguished road

      0  

    Default Ext.layout.ContextItem:init failing in simple test scenario

    Ext.layout.ContextItem:init failing in simple test scenario


    Hi,

    Take the following test scenario:

    Code:
    Ext.onReady(function() {
    
    
        Ext.create('Ext.app.Application', {
            name : 'app',
            appFolder : 'app',
            autoCreateViewport : false,
            launch : function() {
                var vP = Ext.create('Ext.container.Viewport', {
                    layout: {
                        type: 'border'
                    },
                    items: [{
                        html: 'My App',
                        region: 'center'
                    }]
                });
                var panel = Ext.create("Ext.form.Panel", {
                    style: {
                        backgroundColor: "#00FFFF"
                    },
                    layout: {
                        type: 'vbox'
                    },
                    region: 'east',
                    width: 800,
                    initComponent: function(){
                        var me = this;
                        Ext.applyIf(me, {
                            items: [
                                {
                                    xtype: 'textfield',
                                    name: 'name',
                                    fieldLabel: 'Name',
                                    allowBlank: false,
                                    flex: 0,
                                    margins: ''
                                }
                            ],
                            dockedItems: [
                            ]
                        })
                        me.callParent(arguments);
                    }
    
    
                });
                vP.add(panel);
            }
        });
    });
    All it does, it creates a ViewPort, than creates an Ext.form.Panel, and adds that to the viewport. The problem is, that the code fails in Ext.layout.ContextItem in method init, at the following line:

    Code:
    me.hasRawContent = !(target.isContainer && target.items.items.length > 0);
    The reason of the failure is, that the target.items property is an Array, so it has no further items property (it's basically undefined).

    Am I doing something wrong, or it's a bug?

    Also if in the initComponent method of the panel being created I comment out the dockedItems config, I get another error, which comes from Ext.layout.component.Dock:getDockedItems, at this line:

    Code:
    all = renderedOnly ? Ext.ComponentQuery.query('[rendered]', me.owner.dockedItems.items) : me.owner.dockedItems.items,
    me.owner.dockedItems is undefined.

    Question again, if I do something totally bad, or is it a bug also?

    Thanks for Ur reply in advance!

  2. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,509
    Vote Rating
    288
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    If you override a method (initComponent) inline in an Ext.create the callParent will fail.

    This is fine:

    Code:
    Ext.define('MyClass', {
        ...
        initComponent: function() {
            ...
            this.callParent();
        }
    });
    This should also work but is bad practice as xhooks are intended for very minor overrides:

    Code:
    Ext.create('MyClass', {
        ...
        xhooks: {
            initComponent: function() {
                ...
                this.callParent();
            }
        }
    });
    But this will not work:

    Code:
    Ext.create('MyClass', {
        ...
        initComponent: function() {
            ...
            this.callParent();
        }
    });

  3. #3
    Sencha Premium Member
    Join Date
    Mar 2012
    Location
    Norway
    Posts
    24
    Vote Rating
    0
    atomcat is on a distinguished road

      0  

    Default


    Hi,

    Thxs for Ur reply, U are right, I made a wrong test scenario Things are working now fine, maybe yesterday I was tricked by the browser, since things are now working in the app as required (I was changing between v. 4.1.1 RC2, and 4.0.7).

Thread Participants: 1

Tags for this Thread