Copied to clipboard

Flag this post as spam?

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


  • Jose Gonzalez 15 posts 98 karma points
    Aug 12, 2015 @ 13:53
    Jose Gonzalez
    1

    Refresh tree after sorting nodes

    Hi,

    I need to refresh a container with nodes after some sorting.

    How can I refresh the tree from an event handler?

    This is my code:

        void ContentService_Published(Core.Publishing.IPublishingStrategy sender, Core.Events.PublishEventArgs<IContent> args)
        {
            if (args.PublishedEntities.Count() == 1)
            {
                var dirty = (IRememberBeingDirty)args.PublishedEntities.First();
                var isNew = dirty.WasPropertyDirty("Id"); // N.B. In 6.2+ use: content.IsNewEntity(); 
    
                var saveElement = args.PublishedEntities.First();
    
                var itemType = saveElement.ContentType.Alias;
    
                if (itemType != "Event" && itemType != "EventContainer")
                {
                    return;
                }
    
                var parentNode = (itemType == "Event"
                    ? args.PublishedEntities.First().ParentId
                    : args.PublishedEntities.First().Id);
    
                var children = ApplicationContext.Current.Services.ContentService.GetChildren(parentNode).OrderByDescending(page => page.Properties["startDate"].Value);
                ApplicationContext.Current.Services.ContentService.Sort(children, 0, false);
    
                //Reload the tree after sorting.
               //I NEED TO RELOAD THE TREE
            } 
        }
    
Please Sign in or register to post replies

Write your reply to:

Draft