Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Mar 31, 2009 @ 12:47
    Ismail Mayat
    1

    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

  • Peter Gregory 408 posts 1614 karma points MVP 3x admin c-trib
    Mar 31, 2009 @ 14:19
    Peter Gregory
    0

    Im interested in this also as I have a similar issue.

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Mar 31, 2009 @ 15:33
    Darren Ferguson
    0

    [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....

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Mar 31, 2009 @ 15:39
    Ismail Mayat
    0

    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

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Mar 31, 2009 @ 15:53
    Ismail Mayat
    0

    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

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Mar 31, 2009 @ 16:10
    Ismail Mayat
    1

    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

  • Casey Neehouse 1339 posts 483 karma points MVP 2x admin
    Mar 31, 2009 @ 19:09
    Casey Neehouse
    0

    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

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Mar 31, 2009 @ 21:49
    Ismail Mayat
    0

    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

  • Delete me 45 posts 66 karma points
    May 17, 2010 @ 22:59
    Delete me
    1

    Hi there

    After struggling a lot with this, I found this way to reload a node from C#:

    ((BasePage)doc.HttpContext.CurrentHandler).ClientScript.RegisterClientScriptBlock(GetType(),
     Guid.NewGuid().ToString(), "<script>parent.refreshNode("+doc.Id+");</script>");

    Cheers,

    Mathias

  • Anders Brännmark 228 posts 280 karma points
    Jul 05, 2010 @ 08:18
    Anders Brännmark
    0

    Mathias, from where are you executing this code?

     

Please Sign in or register to post replies

Write your reply to:

Draft