-
15 Jun 2008 10:00 PM #1
How to refresh a part of an async tree
How to refresh a part of an async tree
Hi,
Is it possible to refresh the part of an async tree, I mean refresh a given node (the display test could have been changed) and its children.
I've already tried
Code:treeStore.fireEvent(Store.DataChanged,new TreeStoreEvent(treeStore)); //seems to reload the whole tree and doesn't look nice loader.loadChildren(myNode); //add the children to the root node instead of myNode loader.load(myNode); //remove all tree nodes and add the children to the root node instead of myNode
-
16 Jun 2008 2:10 AM #2
I didn't find a nice solution to but maybe you can use:
Regards,Code:store.commitChanges(); myNode.setExpand(true);
Rick
-
16 Jun 2008 6:58 AM #3
Thanks for the help. But actually, it doesn't do what I expect. Let's explain what I am doing
:
- I show an async tree in the west region.
- when I select an item, it opens a form (in center region) to edit the model bound to this tree item.
- I change the name of the item in the form.
- when I click on a "Ok" button, I want to refresh only the tree item that was edit.
Unfortunately, the 2 lines you propose can't do that. For now, the only way I found to do that isbut it refreshes the whole treeCode:treeStore.fireEvent(Store.DataChanged,new TreeStoreEvent(treeStore));

-
16 Jun 2008 7:11 AM #4
zaccret,
I have the very same situation as you. For me, store.update(myModel) updates the name nicely, but not the children. To reload the names of the children as well, you might try somthing along:
HTH,Code:private void relabelTree() { for (final TreeItem child : tree.getRootItem().getItems()) { relabelTree(child); } } private void relabelTree(final TreeItem ti) { store.update((MediaObject) ti.getData()); for (final TreeItem child : ti.getItems()) { relabelTree(child); }
Joachim
-
16 Jun 2008 7:12 AM #5
By the way, generally, I agree, it would be VERY nice to have a way to have an item and all its children reloaded.
-
16 Jun 2008 7:47 AM #6
Thanks, jraue, I found this method a few minutes ago. It is nice.
Thanks also for the children reload solution. However, you're right, it would be nice to have a convenience method to update a node AND its children.
-
18 Jun 2008 2:03 AM #7
Now I would like to add children (one by one) to a given node. It isn't possible with the update method.
I guess I have to use the TreeStore.add(M parent, M item, boolean addChildren) method for each add child. I wonder what will happen if I do that on a node which has not yet been expanded.
-
18 Jun 2008 4:42 AM #8
Try it. My problem so far was that you will get 2+ new TreeItems all pointing to the same Model. I haven't found out how to avoid this either...

-
18 Jun 2008 7:17 AM #9
It works well in both cases (parent already expanded or not).


Reply With Quote