I have an action handler on the save i move document to a folder. What I want to do is after the move refresh the content tree so that the change is reflected in UI. How do i refresh the tree from action handler?
I have an action handler on the save i move document to a folder. What I want to do is after the move refresh the content tree so that the change is reflected in UI. How do i refresh the tree from action handler?
Regards
Ismail[/quote]
My guess is that you'd have to have a custom datatype that injects some javascript into the GUI and traps the publish button click event. Quite a hack, but I don't see how an action handler can communicate with the GUI otherwise....
that refreshed the original folder in the tree. If i can traverse to the parent or the actual target as well then its a winner. My structure is
Contact Forms
Processed
Spam
On hold
at the moment with the code i can refresh original folder so if im moving something from spam to Processed but i also need to then refresh processed. Ps the move is done by custom data type in tab that has drop down that maps to status so you select a status then save and it ends up in selected folder.
After fighting with this same thing last night, here is what I ended up with logic wise.
Being that the sender object will result in being the object that is published, to move an item, you must republish it again after the initial publish. You can move it at a variety of locations. Path will be updated, but, the parentId gets hosed in the process (or at least it seems to).
Since I needed the node to move when saved or published, I ended up with actions for both. The republish only happens on AfterPublish though, as that is the only time I see the problem. I pull a fresh copy of the Document (not the sender copy), and compare the parentId. If they differ, I do the move. If the call action was AfterPublish, I then publish the node again, and update the document cache.
Below is a snippet for refreshing the tree as per the Move/Copy dialog. If it works, I will be amazed.
Cheers for that, I did see some of your tweets about it. In my situation i am not publishing in fact i have action handlers to stop publishing on those folders. Basically the folders are a repository for doc2form submissions.
Refresh tree from actionhandler
Guys,
I have an action handler on the save i move document to a folder. What I want to do is after the move refresh the content tree so that the change is reflected in UI. How do i refresh the tree from action handler?
Regards
Ismail
Im interested in this also as I have a similar issue.
[quote=imayat12]Guys,
I have an action handler on the save i move document to a folder. What I want to do is after the move refresh the content tree so that the change is reflected in UI. How do i refresh the tree from action handler?
Regards
Ismail[/quote]
My guess is that you'd have to have a custom datatype that injects some javascript into the GUI and traps the publish button click event. Quite a hack, but I don't see how an action handler can communicate with the GUI otherwise....
Darren,
Cheers for this. I already have custom data type on item in question so I could try something like this will report back later!
Regards
Ismail
Darren,
Some progress, in the action handler i did
[code]
((BasePage)sender.HttpContext.CurrentHandler).reloadParentNode();
[/code]
that refreshed the original folder in the tree. If i can traverse to the parent or the actual target as well then its a winner. My structure is
Contact Forms
Processed
Spam
On hold
at the moment with the code i can refresh original folder so if im moving something from spam to Processed but i also need to then refresh processed. Ps the move is done by custom data type in tab that has drop down that maps to status so you select a status then save and it ends up in selected folder.
Regards
Ismail
Right,
i can refresh the parent so both by source and target folders get refreshed, here is how i did it:
[code]
Document d = new Document(Settings.Config.RootFolder);
((BasePage)d.HttpContext.CurrentHandler).reloadParentNode();
[/code]
i run this code after my move. ideally would like to then open target however no idea how to do that!
Ismail
Hi Ismail,
After fighting with this same thing last night, here is what I ended up with logic wise.
Being that the sender object will result in being the object that is published, to move an item, you must republish it again after the initial publish. You can move it at a variety of locations. Path will be updated, but, the parentId gets hosed in the process (or at least it seems to).
Since I needed the node to move when saved or published, I ended up with actions for both. The republish only happens on AfterPublish though, as that is the only time I see the problem. I pull a fresh copy of the Document (not the sender copy), and compare the parentId. If they differ, I do the move. If the call action was AfterPublish, I then publish the node again, and update the document cache.
Below is a snippet for refreshing the tree as per the Move/Copy dialog. If it works, I will be amazed.
From umbraco.dialogs.moveOrCopy:
[code]
ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "treeRefresh", String.Format("updateTree({0}, {1}, {2}, '{3}', false);", NodeId, oldParentId, newParentId, newParentPath), true);
[/code]
Of course you will need to do some massaging of the vars.
Case
Casey,
Cheers for that, I did see some of your tweets about it. In my situation i am not publishing in fact i have action handlers to stop publishing on those folders. Basically the folders are a repository for doc2form submissions.
Regards
Ismail
Hi there
After struggling a lot with this, I found this way to reload a node from C#:
Cheers,
Mathias
Mathias, from where are you executing this code?
is working on a reply...