Extjs 嵌套的初始化组件不工作

Extjs 嵌套的初始化组件不工作,extjs,sencha-architect,Extjs,Sencha Architect,我有一个窗口(Ext.window.window),其中我有一个卡片布局中的窗格。我正在将网格动态添加到面板项目中,如下所示: Ext.define('Example.view.ProcessInfoLayout',{ extend: 'Ext.window.Window', requires: [ 'Ext.layout.container.Card', 'Example.view.SubProcessController', 'E

我有一个窗口(Ext.window.window),其中我有一个卡片布局中的窗格。我正在将网格动态添加到面板项目中,如下所示:

Ext.define('Example.view.ProcessInfoLayout',{
   extend: 'Ext.window.Window',
    requires: [
        'Ext.layout.container.Card',
        'Example.view.SubProcessController',
        'Example.view.Info'
    ],
    xtype: 'app--processinfolayout',

    controller: 'main-content-subprocesscontroller',
    layout: 'fit',
    initComponent: function(){

       this.callParent();

        this.header = {
            titlePosition: 0,
            items:[{
                xtype: 'button',
                text: 'Resubmission',
                glyph: 'xf0e2@FontAwesome',
                tooltip: 'Resubmit',
                listeners: {
                    click: 'ResubmissionClick'
                }
            }]
        };
        console.log('thisw')


        this.items =  []

        this.add({
            xtype: 'panel',
            frame: false,
            border: false,
            itemId: 'v6panel',

            layout: {
                type:'card',
                deferredRender: true
            },

           defaultListenerScope: true,

           bbar: ['->',
                {
                    itemId: 'card-prev',
                    text: '« Previous',
                    handler: 'showPrevious',
                    disabled: true
                },
                {
                    itemId: 'card-next',
                    text: 'Next »',
                    handler: 'showNext'
                }
            ],

            items: [],
            initComponent: function() {
                var me = this;
                me.callParent();



                me.store = Ext.getStore('app-main-store-' + me.up('app-main-processinfolayout').processData.id);

                if (!me.store) {
                    me.store = Ext.create('Example.store.ProcessInfo', {
                        storeId: 'app-main-store-' + me.up('app-main-processinfolayout').processData.id,
                        room: me.up('app-main-processinfolayout').processData.id
                    });

                    me.store.proxy.url = Ext.String.format(me.store.proxy.url, 
                                                           me.up('app-main-processinfolayout').processData.id);
                }




              me.store.on('load', function(store, records, successful, eOpts) {
                console.log('@@@@')
                me.fireEvent('refreshProcessInfoLayoutView', me, records);
              });

            },

            listeners:{
                beforerender: function(obj) {
                    console.log('Hey Australia')
                    obj.store.load();
                },
                refreshProcessInfoLayoutView: 'refreshProcessInfoLayoutView',

               scope: 'this'


            },
            refreshProcessInfoLayoutView: function(obj, records) {
                console.log('thise')
                console.log(records[0].data.processes)
                    if (records[0].data.v6_processes) {
                        for (elem in records[0].data.processes) {
                            var subprocessInfo = {
                                xtype: 'app-main-cycle-info',
                                processId: records[0].data.processes[elem],
                                itemId: 'card-' + elem
                            };
                            obj.add(subprocessInfo);
                        }
                }
            },

            showNext: function () {
                this.doCardNavigation(1);
            },

            showPrevious: function (btn) {
                this.doCardNavigation(-1);
            },

            doCardNavigation: function (incr) {
                var me = this;
                var l = me.getLayout();
                var i = l.activeItem.id.split('card-')[1];
                var next = parseInt(i, 10) + incr;
                l.setActiveItem(next);

                me.down('#card-prev').setDisabled(next===0);
                me.down('#card-next').setDisabled(next===this.down('#v6panel').store.getCount() - 1);
            }
        })


    }
})

它将控制台日志打印到此为止。在此之后,它给出的错误是…uncaughttypeerror:me.items.insert不是一个函数。我做错了什么。请建议。

不要做
这个.callParent()this.header
this.items
之前,在
initComponent
中选择code>。以后再做。这是因为一旦调用了
This.callParent()您的组件是实例化的,因此尝试像
this.items=[]
这样的东西只会把事情搞砸

此外,不是:

this.items = [];
this.add({stuff});
做:


不要做
this.callParent()this.header
this.items
之前,在
initComponent
中选择code>。以后再做。这是因为一旦调用了
This.callParent()您的组件是实例化的,因此尝试像
this.items=[]
这样的东西只会把事情搞砸

此外,不是:

this.items = [];
this.add({stuff});
做:


处理嵌套项和
initComponent
函数时,可以使用
xhooks
config,以便
callParent()
可以正常工作:

Ext.define('Example.view.ProcessInfoLayout', { 
    // ...
    xhooks: {
        initComponent: function(){
            this.callParent();
            // ...
            this.add({
                xtype: 'panel',
                // ...
                items: [],
                initComponent: function() {
                    // ...
                }
            });
        }
    }
});

查看。

处理嵌套项和
initComponent
函数时,可以使用
xhooks
配置,以便
callParent()
可以正常工作:

Ext.define('Example.view.ProcessInfoLayout', { 
    // ...
    xhooks: {
        initComponent: function(){
            this.callParent();
            // ...
            this.add({
                xtype: 'panel',
                // ...
                items: [],
                initComponent: function() {
                    // ...
                }
            });
        }
    }
});

请看。

如果我根据上述注释修改代码,它会给出错误为…Uncaught TypeError:无法读取Undefinedy的属性“length”。您的问题很容易解决,但如果不查看它的实际操作,则很难找到它。考虑张贴小提琴。我想…它不能添加面板到窗口,如果我根据上面的注释修改代码,它会给……错误的类型错误:不能读取未定义的属性“长度”。你的问题很容易解决,但是在没有看到它的情况下很难找到。考虑张贴小提琴。我想…它不能把面板添加到窗口,你必须把参数传递给这个。CalpApple()。这样,调用父(参数),否则它将不工作,通过参数,但它仍然给出相同的问题,然后使用Ext.Apple来应用新的属性。不要使用嵌套的不完整项,否则将不起作用。只有一次,如果您试图修改实例上的
initComponent
,它将被调用
callParent()。我建议你重新考虑你的方法。在这里,我将面板添加到窗口中,然后根据一些数据,我将网格添加到卡片布局中的面板中。我是否应该采用这种方法:我将在那里创建一个panel.js,我将添加所有网格,然后在window.js中,我将该面板作为一个项目添加@Evan您必须像这样将参数传递给此.callParent().callParent(参数),否则它将不起作用。我已经传递了参数,但它仍然给出了相同的问题。请使用Ext.apply应用新属性。不要使用嵌套的不完整项,否则将不起作用。只有一次,如果您试图修改实例上的
initComponent
,它将被调用
callParent()。我建议你重新考虑你的方法。在这里,我将面板添加到窗口中,然后根据一些数据,我将网格添加到卡片布局中的面板中。我是否应该采用这种方法:我将在那里创建一个panel.js,我将添加所有网格,然后在window.js中,我将该面板作为一个项目添加@埃文