Reputation: 656
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.
Upvotes: 5
Views: 16825
Reputation: 2148
// 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
});
Upvotes: 0
Reputation: 18980
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
}
});
Upvotes: 0
Reputation: 728
This is working for me. I'm using MVC and this code is called in my controller.
treeStore.getRootNode().removeAll();
treeStore.load();
Upvotes: 9
Reputation: 2237
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?
Upvotes: 0
Reputation: 4506
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()
)
Upvotes: 0