Filtering ins Calendar Control


How do we perform a filterring inside the control.

For eg. I have certain offices in my drop down and want to show only events that are going to take place at a particular selected office.

 Thanks in Advance.

Jul 24, 2008 13:02

You can use the OnFilter event. This code removes every event that doesn't come from the users chosen department or the sites main calendar.

<EPiServer:Calendar ID="CalendarList" PageTypeID="28" runat="server" NumberOfDaysToRender="360" ExpandAllDays="false" OnFilter="FilerEvents">

 Code behind:

protected void FilerEvents(object sender, EPiServer.Filters.FilterEventArgs e)
 PageDataCollection Pages = e.Pages;
 PageData MainCalender= GetPage((PageReference)StartPage["ShowCalendarFrom"]);

 for (int i = 0; i < Pages.Count; i++)
  PageData iPage = Pages[i];
  if (iPage.ParentLink != MyDepartment.PageLink&&iPage.ParentLink!=MainCalender.PageLink)

Jul 25, 2008 9:09

Thanks very much.

I would like to know what is "MyDepartment" in the above code?

Jul 25, 2008 11:42


MyDepartment is a PageData object that I set to the calendarpage that my users have chosen.
In my site there is a lot of different calendapages. That's why I'm comparing the parent link in the events.
You could also choose to use a property on every event instead. And then you could compare to that.


Jul 25, 2008 14:35