+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / event filter expression

event filter expression

2 posts, 0 answered
  1. Stephen
    Stephen avatar
    70 posts
    Registered:
    09 Jun 2009
    17 Nov 2010
    Link to this post
    I want to display a list of events based on certain conditions. My filter expression for the EventsView is like following, but I got an error "Left operand '(Categories' is not supported....". Is there any way to compose an expression with 'AND' and 'OR'? Thanks.

    Publication_Date <= "#now" AND Expiration_Date > "#now" AND Event_End >= "#now" AND (Categories LIKE "%CustomCategoryName%" OR Category IN ("CategoryName"))
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    17 Nov 2010
    Link to this post
    Hello Stephen,

    OR operand is not supported you can use IN without problems. You can achieve your goal by using a custom control that inherits from EventsView where you have to override CreateDataSource method and use LINQ to return filtered list of items based on "OR" and "IN" condition.

    public class EventsViewCustomControl : EventsView
    {
     
        public override string ItemListTemplatePath
        {
            get
            {
                return "~/Sitefinity/ControlTemplates/Events/ListPageMaster.ascx";
            }
     
        }
     
        public override string SingleItemTemplatePath
        {
            get
            {
                return "~/Sitefinity/ControlTemplates/Events/ListPageDetails.ascx";
            }
     
        }
     
     
        public override Type LocalizationAssemblyInfo
        {
            get
            {
                return this.GetType();
            }
            set
            {
                base.LocalizationAssemblyInfo = value;
            }
        }
     
        public override Type AssemblyInfo
        {
            get
            {
                return this.GetType();
            }
            set
            {
                base.AssemblyInfo = value;
            }
        }
     
        
     
          protected override IList CreateDataSource()
          {
             var allItems =  base.CreateDataSource();
            var list = allItems.Cast<IContent>().ToList().OrderByDescending(c => c.GetMetaData("Publication_Date")  .........  DO YOUR CONDITION HERE);
            
           return filteredList;
         }
     
    }


    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered