How do you Sort By Property date/time if a property is not empty
So I have a list of items. Some of my nodes have the option to put in a date/time property that are in the list. I want to be able to list items by ascending or descending based on the Date/Time property only IF the date/time property is filled in.
Here is my simple list right now. How do I use the startDateTimeProperty to sort the list only IF the node has that property and if it filled in? Thanks in advance
what are you wanting to do with those items in your enumeration that have an empty eventTimeHeader? Exclude? or place at the top or bottom of the list?
How do you Sort By Property date/time if a property is not empty
So I have a list of items.
Some of my nodes have the option to put in a date/time property that are in the list. I want to be able to list items by ascending or descending based on the Date/Time property only IF the date/time property is filled in.
Here is my simple list right now.
How do I use the startDateTimeProperty to sort the list only IF the node has that property and if it filled in?
Thanks in advance
what are you wanting to do with those items in your enumeration that have an empty eventTimeHeader? Exclude? or place at the top or bottom of the list?
but I think you can just add an OrderBy
@Model.Children.Where("!hideFromAllMenus").OrderBy("eventTimeHeader")
or
@Model.Children.Where("!hideFromAllMenus").OrderByDescending("eventTimeHeader")
if you need to get more logic in there... then you may have to revert to linq statements..
eg OrderBy(x => (DateTime.Parse(x.HasValue("eventTimeHeader", x.GetPropertyValue("eventTimeHeader"), DateTime.Now.ToString()).ToString()))
but that may mean further refactoring... to get your enumeration as a DynamicNodeList rather than a dynamic
is working on a reply...