Copied to clipboard

Flag this post as spam?

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


  • jonok 297 posts 658 karma points
    Jul 21, 2011 @ 04:54
    jonok
    0

    ClientTools.SyncTree not working when moving a Document

    I've got a date folder system that moves an event to a year->month node

     

    2011
    -03

    umbraco.BasePages.BasePage.Current.ClientTools.SyncTree(documentObject.Parent.Path, true);

  • jonok 297 posts 658 karma points
    Jul 21, 2011 @ 05:02
    jonok
    0

    OK I submitted this post by accident and the forum throws an error when I try to edit it, so here's the real question:

    I've got a date folder system for events with the following structure that corresponds to a date property on the event Document Type:

    2011
    -03
    --event

    When saving and publishing an event it checks if the year and month nodes exist and creates them if needed, then moves the event node into its corresponding parent month node. The tree is refreshing whenever a month node is created (by calling ClientTools.SyncTree), but if the month node already exists and I just try to move the node then the tree doesn't remember the position (even though I'm still calling ClientTools.SyncTree) and collapses back to the root home node. Has anybody had any problems with ClientTools.SyncTree not working properly when moving nodes to existing parent nodes?

  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Jul 22, 2011 @ 11:42
    Bo Damgaard Mortensen
    0

    Hi jonok,

    Withouth knowing exactly what the ClientTools.SyncTree() methods does, wouldn't it be enough to call umbraco.library.RefreshContent() instead? :-) That's what I did when I'm creating the structure you're working on.

  • jonok 297 posts 658 karma points
    Jul 23, 2011 @ 01:57
    jonok
    0

    Hi Bo, I'm also calling RefreshContent() but it doesn't seem to work. The ClientTools.SyncTree() works if I call it before RefreshContent() . Its strange because if I'm creating a parent node, and then moving the document to the newly created parent then its fine, but the same code (without the creation of the parent node) then the tree collapses. I'm doing all of this in the Document.AfterSave event handler.

  • jonok 297 posts 658 karma points
    Jul 23, 2011 @ 02:04
    jonok
    0

    I think I've just solved it by calling SyncTree and passing in the parent of the parent path, eg.
    umbraco.BasePages.BasePage.Current.ClientTools.SyncTree(documentObject.Parent.Parent.Path, true);

    Previously I was just calling it with the parent path, eg.
    umbraco.BasePages.BasePage.Current.ClientTools.SyncTree(documentObject.Parent.Path, true);

    Don't know why it works one way and not the other.

  • Søren Linaa 255 posts 208 karma points
    Aug 26, 2011 @ 13:04
    Søren Linaa
    1

    I'm not sure if this is the correct approach - but it seems to do the job.

     string _returnUrl = "editContent.aspx?id=" + sender.Id.ToString() + "&isNew=true";
    BasePage.Current.ClientTools
          .ChangeContentFrameUrl(_returnUrl);

     

    Cheers

Please Sign in or register to post replies

Write your reply to:

Draft