2

ツリー ストアを更新する方法は?

私はそのようにしようとしました:

Ext.getStore('myStore').setRootNode({child: []});

そして、ストアはサーバーに子を持つように要求しますが、時には二重に子を与えてくれます。私のツリーでは、次のようなものが得られます。

child1
child2
child1

また、JavaScriptエラーもあります:

Uncaught TypeError: Cannot read property 'internalId' of undefined
Ext.define.updateIndexes ext-all-debug.js:61588
Ext.define.onAdd ext-all-debug.js:61513
Base.implement.callParent ext-all-debug.js:3728

それはバグですか、それとも何か間違っていますか?

4

1 に答える 1

1

使用している extjs のバージョンはわかりませんが、load メソッドを使用して 4.1 でストアを更新する方法は次のとおりです (パラメーターがある場合とない場合がありますが、私にはあります)。

this.getStore('MyTreeStore').load({ params: { id: this.getId().getValue()} });

ストアは、以前のロードからの重複のない新しいレコードで更新されます。

私は自分の店を次のように設定しています:

Ext.define('MyApp.store.MyTreeStore', {
    extend: 'Ext.data.TreeStore',
    model: 'MyApp.model.MyTreeModel',

    root: {
          children: []
    },

    proxy: {
        type: 'ajax',
        url: '/MyApp/Chart/GetTree'
    },
    fields: [
         { name: 'id', type: 'int' }
    ]
});

私のツリーは次のようになります。

Ext.define('MyApp.view.chart.MyTree', {
    extend: 'Ext.tree.Panel',
    alias: 'widget.mytree',

    id: 'MyTree',
    store: 'MyTreeStore',
    width: 350,
    height: 320,
    border: false,
    rootVisible: false,
    singleExpand: true
});
于 2012-05-10T21:43:33.410 に答える