PDA

View Full Version : Update TreeStore data



houngj
28 May 2015, 6:59 PM
I've been trying for update my TreeStore data with an Ajax response from my server. My TreeStore is initially poppulated through the proxy config but I need to be able to update my TreeStore after I trigger a Ajax request.

Is there anyway to just replace the data with the new Ajax response?

f.baron
28 May 2015, 11:08 PM
If the ajax request returns a well formed JSON for trees, simply remove and append:

tree.getStore().getRootNode().removeAll();
tree.getStore().getRootNode().appendChild(rootFromAJAXRequest.children);


JSON should be like this:


{
"name":"root",
"children":[{
"name":"int-1",
"children":[{
"name":"leaf-2",
"children":[],
"leaf":true
}, {
"name":"leaf-3",
"children":[],
"leaf":true
}]
}]
}