2012-05-10 9 views
2

Tree Storeを更新するにはどうすればいいですか?extjs refresh tree store

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

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 

それはバグですか、私は何か間違ったことをやっているの?

答えて

1

私はあなたが使用しているのExtJSのバージョンはよく分からないが、ここで私は(あなたがまたはパラメータを持っていない可能性があり、私は1つを持っている)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 
}); 
+0

はい、私は4.1を使用していて、私は、おかげでそれをしようとします。 – Charles

+0

私は問題を解決しました。私は非常に閉じた2回のリフレッシュを行っていました。だから私はダブルスを得たのです。 – Charles