开发者

How to reload TreeStore?

I have nestedlist with treestore. While loading first time the store is loaded perfectly and list is being displayed according to the store. When i click refresh button , my treestore should get reloaded with new data (with same data model as the first time) and nested list also need to be reloaded with new set of data.

Below is my treestore definition

rightPaneStoreData = getFolderListData();

rightPaneStore =new Ext.data.TreeStore({

   autoLoad:false,

   model: 'FIMT.models.rightPaneModel',

   root: rightPaneStoreData,
   proxy: {

   type: 'memory',

   reader: {

       type: 'tree',
       root: 'items'
       }

   },
   listeners: {
       datachanged: function(records){
          开发者_开发百科 alert("datachanged");
           }
   }

   });

rightPaneStore.load();

In Ext.data.JsonStore i have accomplished the same using store.loaddata() method. But i couldnt find loaddata() method for TreeStore.

Kindly help me.


This is working for me. I'm using MVC and this code is called in my controller.

treeStore.getRootNode().removeAll();
treeStore.load();


The TreePanel doesn't have a store like a JsonStore. It automatically shows all nodes, and reloads when needed.

In case your rootNode (rightPaneStoreData) is an AsyncTreeNode (loaded through AJAX), you can use:

rightPaneStoreData.reload()
(because rightPaneStoreData is your root node).

or alternatively (more generic):
tree.root.reload();
(where tree is a reference to your tree)

If it isn't an ASyncTreeNode, you'll have to do it manually. Call your getFolderListData() function again, and assign the new root to the tree. (tree.setRootNode())


You can reload the tree by using a memory proxy. See the answer in How to update the Nested List/Tree Store in Sencha Touch?


treeStore.getRootNode().removeAll();
treeStore.setRootNode({
  id: rootNodeId,
  text: 'root'
  // other configs in root
});
// if you had non-standard children loads, then you would need to call:
treeStore.getProxy().load();
// if you had non-standard children loads, and you had params in your load, then you would need to call:
treeStore.getProxy().load({
  params: {
    node: rootNodeId
  }
});


// Remove all current children if clear on load not set 
if (!treeStore.clearOnLoad) { 
    record.removeAll(); 
} 

// Call load, refreshing our view when done... 
var viewRefresher = function() { 
    view.refresh(); 
}; 

treeStore.load({ 
    node: record, 
    callback: viewRefresher 
});  
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜