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

Forums / General Discussions / event filter expression

event filter expression

8 posts, 0 answered
  1. Rabindra
    Rabindra avatar
    106 posts
    Registered:
    17 May 2009
    24 Oct 2009
    Link to this post
    I want to display all events for present day and future sorted by earliest on first.
    So in Events View, I added "Event_Start ASC" in "Sort Expression".
    In "FilterExpression" I added Event_Start >= "#now" AND Event_End >= "#now"

    Problem with this is that Events View is only showing future events and not todays events.
    What is wrong here?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    25 Oct 2009
    Link to this post
    Hello Rabindra,

    Most probably there is a difference between website and SQL server time. In this case the events are not shown, so if you create a simple test with hadrcoded date ( for instance date time now -1) you should see the events.

    We assume that  today is 25th and  we are adding 24th to our filter

    Publication_Date >= "2009/10/24" AND Expiration_Date >= "#now"

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Rabindra
    Rabindra avatar
    106 posts
    Registered:
    17 May 2009
    26 Oct 2009
    Link to this post
    I didn't have to change anything. All events are showing.
    The event I was looking wasn't appearing because the event start time was 9-10 am and I was checking the site at noon. Even though the start date and the day I was browsing was the same day, it seems "Events View" doesn't populate all events between 12 am - 11:59 pm.
    Is there a way to get all events between 12 am - 11:59 pm of a single day?

    My other question is if I have a query string eg.
    http://myweb.com/events.aspx?fromDate=17/10/2009 12:00:00 AM&toDate=17/10/200911:59:59 PM 

    I can write a code that retrieves "fromDate" and "toDate" from querystring but how do I populate events data in "Events View" control?

    thanks
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    26 Oct 2009
    Link to this post
    Hi Rabindra,

    Thank you for getting back to us.

    Since you have been looking for an event that is supposed to have started in the morning and it did not appear, then you must have configured the events view control not to show Past Events and the event's end time has passed. As a proof that the events control works as expected, I have created an event that starts at 26 Oct 2009, 09:57:AM (this is today) and ends at 26 Oct 2009, 07:00:PM (see attached image). Then I have set the events control not to display past events. Note that since this event is still in progress it also appears on the events view control (see attached images).

    As for your second question, I would encourage you to take a look at the following article: Using ContentManager with Events. There you can find a list of all metafields that you can form filter expressions on. Since you wish to create an events view that will be filterable by the query string you have to create a custom Events View control that will get the query string values and form filter expressions based on that. Here is sample code to get you started. Note that you should modify it to read the query string values:
    using System;
    using System.Collections.Generic;
    using System.Collections.Specialized;
    using System.Linq;
    using System.Web;
    using Telerik.Framework.Web.Design;
    using Telerik.Events.WebControls;
    using System.Collections;
    using Telerik.Cms.Engine.ContentViewFiltering;
    using System.Web.UI.WebControls;
    using Telerik.Events;
     
    namespace Telerik.Samples.Events.WebControls
    {
        /// <summary>
        /// Summary description for CustomEventsView
        /// </summary>
        [ControlDesigner("Telerik.Events.WebControls.Design.EventsViewDesigner, Telerik.Events")]
        public class CustomEventsView : EventsView
        {
     
            public override string ItemListTemplatePath
            {
                get
                {
                    return base.ItemListTemplatePath;
                }
                set
                {
                    base.ItemListTemplatePath = value;
                }
            }
     
            public override string SingleItemTemplatePath
            {
                get
                {
                    //Provide the path to your Single News Item template
                    return base.ItemListTemplatePath;
                }
                set
                {
                    base.SingleItemTemplatePath = value;
                }
            }
           protected override void  OnPreRender(EventArgs e)
            {
                base.OnPreRender(e);
                HttpContext currentContext = HttpContext.Current;
                HttpRequest request = currentContext.Request;
                EventsManager man = new EventsManager("Events");
                ContentFilterBuilder filterBuilder = new ContentFilterBuilder(this);
                string parameterName;
                string parameterValue;
                //Here you should add a filter expression for each query string paremeter and its value
                //as in your sample you will have string parameterName = "Event_Start"; string parameterValue = value form queryString
                filterBuilder.AddFilter(new ContentFilterStatement(parameterName, parameterValue, ContentFilter.Condition.GreaterThan, ContentFilter.JoinType.And));    
            }            
     
        }
    }


    You should add this to the ~/App_Code directory and then add this control to the toolbox:
    <add name="Custom Events View" section ="Telerik Samples" type="Telerik.Samples.Events.WebControls.CustomEventsView, App_Code"/>



    Sincerely yours,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Rabindra
    Rabindra avatar
    106 posts
    Registered:
    17 May 2009
    27 Oct 2009
    Link to this post
    hi Radoslav,
    First part of the question:
      Yes, I have past events unchecked. In your example when you viewed your webpage you could see the event because it was still in progress. Your event end time in at 7 pm. If you had viewed your page after 7 pm, you wouldn't see that event in Event View. I am talking about "Event View" and not "Event Schedule View". Is it possible to view all events of the same day including all events whose time has expired?
    eg. Event 1
    start date: 27 Oct 2009  at 9 am
    End Date: 27 Oct 2009 at 10 am
    If I browse the page on 27 Oct 2009 at 11 am, I would like to see this event. Right now I can't as the end time has passed.

    Second part of the question:
        I will have to follow your instruction and will let you know if I get stuck.
  6. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    27 Oct 2009
    Link to this post
    Hello Rabindra,

    Thank you for getting back to me.

    The page that I have made screenshot of contained both events view and events schedule view. If you have Past Events unchecked from the Events View control there is no way you can show expired events. If you wish to show expired events you should add the Past Events check. You should filter the events based on filters concerning event start date, event end date or publication date and expiration date (see attached image). The other option is to work with the solution I have provided in my previous post.

    Sincerely yours,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  7. Rabindra
    Rabindra avatar
    106 posts
    Registered:
    17 May 2009
    29 Oct 2009
    Link to this post
    If you have Past Events unchecked from the Events View control there is no way you can show expired events. If you wish to show expired events you should add the Past Events check.
    - So you mean, even if I try to view events view one second after the event is expired on the same day, I won't be able see it. Is that right? I always thought Past event meant for yesterday's events but included all events from today.

    On the second, I didn't understand where to put what.
    Here is what I did. I created class file named "CustomEventsView.cs" in App_code folder.
    I added this in Toolbox.
    <add name="Custom Events View" section ="Telerik Samples" type="Telerik.Samples.Events.WebControls.CustomEventsView, App_Code"/>

    Where do I create .ascx file? or do I make a copy of ContentViewItemView.ascx and it's resource file, rename them to CustomEventsView and place it in UserControls folder?
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    29 Oct 2009
    Link to this post
    Hello Rabindra,

    Telerik.Samples.Events.WebControls.CustomEventsView is a custom control and it should remain in App_Code folder. For this control you need to add templates - ListPageMaster and ListPageDetails by overriding ItemListTemplatePath and SingleItemTemplatePath.

    public override string ItemListTemplatePath
       {
           get
           {
               return "~/Sitefinity/Admin/ControlTemplates/Events/Modes/ListPageMaster.ascx";
           }
           
       }
     
       public override string SingleItemTemplatePath
       {
           get
           {
               return "~/Sitefinity/Admin/ControlTemplates/Events/Modes/ListPageDetail.ascx";
           }
           
       }

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
8 posts, 0 answered