Reputation: 7299
I've seen similar posts on this on the umbraco forum, but none that I have read have addressed my exact problem.
I have an action handler that is called when a node is published. I would like for the last thing the action handler does be to refresh the content tree, starting at the node's parent.
Assume the following structure:
Suppose I publish the node, "Zi". I would like for the "Z" folder to refresh (and keep "Zi" selected in the editor).
Is this possible?
The closest I managed to come was using
umbraco.BasePages.BasePage.Current.ClientTools.SyncTree(doc.Parent.Path, true);
This did refresh the tree, but it also collapsed all nodes. I'd like to keep the "Z" node expanded in the example I gave above.
Upvotes: 1
Views: 3727
Reputation: 320
To keep the sub-folders (Za, Zi, Zu) open and highlight Zi, you shold pass the path of zi rather than the path of Z. This will refresh and highlight Zi but it will refresh the subtree for Z as well.
So-
umbraco.BasePages.BasePage.Current.ClientTools.SyncTree(doc.Path, true);
If Z does not refreshed enough then you could call SyncTree for Z first, then for Zi.
umbraco.BasePages.BasePage.Current.ClientTools.SyncTree(doc.Path, true);
umbraco.BasePages.BasePage.Current.ClientTools.SyncTree(doc.Parent.Path, true);
Ultimately these calls end up as javascript on the page. In Umbraco 4.7.0 (I haven't tried it on anything newer) the call -
UmbClientMgr.mainTree().syncTree('-1,1000,10001', true);SyncTree("-1,1000,1001", true);
- ends up as -
UmbClientMgr.mainTree().syncTree('-1,1000,1001', true);
- in the page's javascript when the page html comes back.
So outputting that javascript directly instead of using UmbClientMgr should allow you to put multiple lines in.
In practice calling for the parent node's path will close the parent node's subtree and refresh the parent node. A subsequent call for the child node will expand the parent subtree to show and highlight the child node.
Upvotes: 4