Copied to clipboard

Flag this post as spam?

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


  • Rob Watkins 369 posts 701 karma points
    Nov 30, 2010 @ 16:42
    Rob Watkins
    0

    Reloading content tree on programmatic tree change

    (4.5.2)

    Have searched for this and doesn't seem to be a definitive answer; I have written a datatype to allow a client to edit diary items stored in a DateFolders hierarchy in a list form for simplicity. 

    Everything is working apart from the delete. I am deleting nodes by providing a LinkButton with the following handler in the user control:

    protected void DeleteItemClicked(object sender, EventArgs e)
    {
      Document doc = new Document(Convert.ToInt32(((LinkButton)sender).CommandArgument));
    
        doc.UnPublish();
        doc.delete();
    
        umbraco.library.UpdateDocumentCache(DiaryRootID);
        umbraco.library.RefreshContent();
            Response.Redirect(String.Concat("editContent.aspx?id=", DiaryRootID));              
    }
    DiaryRootID is the ID of the node for the parent of all the dated folders.
    This deletes the node fine; it is instantly no longer available from the front end site, and does not appear in the list I am constructing; however, it still appears in the content tree.
    An alternative is to do this instead of the Redirect:
    umbraco.BasePages.BasePage.Current.ClientTools.RefreshTree();
    umbraco.BasePages.BasePage.Current.ClientTools.ChangeContentFrameUrl(String.Concat("editContent.aspx?id=", DiaryRootID));
    
    ...this works, but results in the page being loaded with old info, then loaded again with the correct data as the client-side loads happen.
    I can avoid the flash of old data by refreshing the item list in the user control, but I still get the ugly double load, as I need to call ChangeContentFrameUrl in order to resync the tree after refresh. Is there any way to resync the tree to the current node, in situations where you know the current node is already the one you want?
Please Sign in or register to post replies

Write your reply to:

Draft