[Dojo-interest] Re Asked: How to update/refresh the (display of a) tree widget?

theKryz Treschklingen at gmail.com
Tue Aug 26 13:36:01 UTC 2008


I need to reload a tree as well! In my case, the ItemFileReadStore uses
server-generated JSON, which changes in time. How can the tree be reloaded /
updated / refreshed?

Thanks,
chris


Yingqi wrote:
> 
> I have dynamically created a tree and connect that to an ItemFileReadStore
> (which instead of reading a static file, it reads from an object literal
> with same structure), but the problem is whenever I change anything in
> object literal or itemfilereadstore I can not find a way to update/refresh
> tree. So does anyone know how to refresh the tree display?
> 
> Here is the code sample:
> 
> var jsonData = null;
> var json_item_store = null;
> 
> function init() {
> jsonData = {};
> jsonData['identifier'] = "name";
> jsonData['label'] = "name";
> jsonData['items'] = [];
> jsonData['items'].push({name:'Argentina', type:'country'});
> jsonData['items'].push({name:'Egypt', type:'country'});
> json_item_store = new dojo.data.ItemFileReadStore({data:jsonData});
> 
> var tree = new dijit.Tree(
> {
> id: "dijit_tree_results",
> labelAttr: "name",
> label: "results",
> store: json_item_store,
> style:
> "width:260px;height:300px;margin-top:5px;margin-left:5px;background-color:#ffffff"
> },
> dojo.byId('tree')
> );
> 
> tree.startup();
> }
> 
> function updateTree() {
> jsonData['items'][0]['name'] = "Brazil";
> var json_item_store2 = new dojo.data.ItemFileReadStore({data:jsonData});
> 
> var tree = dijit.byId("dijit_tree_results");
> //even create a new store doesn't help
> tree.store = json_item_store2;
> }
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-programmatically-update-refresh-the-display-of-a-tree-widget--tp17873425p19162212.html
Sent from the Dojo mailing list archive at Nabble.com.



More information about the Dojo-interest mailing list