سؤال

I have this code

Ext.define('Header', {

getItems: function() {
    return somepanel;
}

items: [this.getItems()]

});

This is not working. i get error that getItems is not defined

هل كانت مفيدة؟

المحلول

Your question is a bit vague, however, you can add a template method:

Ext.define('MyContainer', {
    extend: 'Ext.container.Container',

    initComponent: function() {
        this.items = this.createItems();
        this.callParent();
    },

    createItems: function() {
        return [{title: 'Foo'}];
    }
});

نصائح أخرى

this is the context where Ext.define('Header'...) is being executed. I guess that's the window.

I don't get properly what you want to do, but if you want to fill item property with the function you need to call it:

items: function() {
    return somepanel;
}()
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top