London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Filtering ins Calendar Control

Vote:
 

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.

#22136
Jul 24, 2008 13:02
Vote:
 

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)
  { 
   Pages.RemoveAt(i);
   i--;
  }
 }
}

#22147
Jul 25, 2008 9:09
Vote:
 

Thanks very much.

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

#22151
Jul 25, 2008 11:42
Vote:
 

 

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.
if(iPage["OfficeName"]!="Huvudkontoret")
Pages.remove.....

 

#22157
Jul 25, 2008 14:35
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.