0

ここに画像の説明を入力

パネルの数は、ストアからのデータの数に依存し、上記の形式、つまり 2 列でレンダリングする必要があります

私のコードは

Ext.define('ConnectionsFeed.view.Communities',{
     extend: 'Ext.container',
     requires: 'ConnectionsFeed.store.Communities',
     store: 'Communities',
     alias: 'widget.communities',
     layout: 'table',

 initComponent: function(){
  var x = this;
  this.store.each(function(item){
   x.add(new Ext.panel.Panel());
  });
 }
});

Ext.create('ConnectionsFeed.view.Communities',{
   renderTo: Ext.getBody()
});

しかし、次のエラーが発生します

> Uncaught TypeError: Cannot read property 'isInstance' of undefined
> ext-all.js:21 (anonymous function) ext-all.js:21 Ext.apply.doProcess
> ext-all.js:21 (anonymous function) ext-all.js:21 Ext.apply.require
> ext-all.js:21 (anonymous function) ext-all.js:21 Ext.apply.doProcess
> ext-all.js:21 Ext.apply.doProcess ext-all.js:21 Ext.apply.process
> ext-all.js:21 Ext.Class.c ext-all.js:21 Ext.ClassManager.create
> ext-all.js:21 Ext.apply.define ext-all.js:21 (anonymous function)
4

3 に答える 3

1

また、コンテナには店舗がありません。initComponentにインスタンスを作成し、ロードする必要があります。

Ext.define('ConnectionsFeed.view.Communities', {
    extend: 'Ext.container',
    requires: 'ConnectionsFeed.store.Communities',
    store: 'Communities',
    alias: 'widget.communities',
    layout: 'table',

    initComponent: function() {
        var x = this;

        x.store = Ext.create('ConnectionsFeed.store.Communities');

        //If you override initComponent you need to call its parent
        x.callParent();
    },
    afterRender: function() {
        var x = this;

        x.store.load({
            scope: x,
            //Callback function after the store has loaded
            callback: function(records, operation, success) {
                Ext.each(records, function(record) {
                    //Your logic of add a panel here
                    x.add(Ext.create('....'));
                });
            }
        });

        x.callParent();
    }
});

Ext.create('ConnectionsFeed.view.Communities', {
    renderTo: Ext.getBody()
});​
于 2012-08-20T13:20:59.100 に答える
1

initComponent の最後に this.callParent() の呼び出しがありません。

于 2012-08-20T10:56:26.110 に答える