Copied to clipboard

Flag this post as spam?

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


  • Anthony Barsotti 26 posts 66 karma points
    Sep 16, 2014 @ 16:11
    Anthony Barsotti
    0

    Sort by first date in Multi-Date Picker

    I'm trying to sort a series of events on an event page by their showtime but since each event can have more than one showtime I've used a multi-date picker datatype. I only want to sort based on the first showtime and display the nodes in that order but I'm having trouble figuring out the best way of doing this. Currently I've tried the following:

        dynamic shows = Library.NodeById(1076).Children.OrderBy("eventDate[0] descending");

        foreach(var show in shows)

    and

        dynamic shows = Library.NodeById(1076).Children

        foreach(var show in shows.OrderBy("eventDate[0] descending"))

    but both of these throw errors.

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Sep 16, 2014 @ 18:27
    Dennis Aaen
    0

    Hi Anthony,

    Since I donĀ“t know which package you are using for your Multi-Date Picker I would try to help you from the top of my mind. But what happen if you do something like this does this do any difference.

    dynamic shows = Library.NodeById(1076).Children.OrderBy("eventDate descending").First();
    
    foreach(var show in shows){

    }

    Or

    dynamic shows = Library.NodeById(1076).Children;

    foreach(var show in shows.OrderBy("eventDate descending").First()){

    }

    Here are some documentation about the First() method. http://our.umbraco.org/documentation/Reference/Querying/DynamicNode/Collections#First%28%29

    Hope this helps,

    /Dennis

  • Anthony Barsotti 26 posts 66 karma points
    Sep 16, 2014 @ 18:33
    Anthony Barsotti
    0

    Thanks for the reply, I'm using UComponents. That solution is throwing the following error though "At least one object must implement IComparable."

Please Sign in or register to post replies

Write your reply to:

Draft