Print Page | Close Window

Filtering in Calendar Control

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Calendar
Forum Description: Topics Related to Codejock Calendar
URL: http://forum.codejock.com/forum_posts.asp?TID=19860
Printed Date: 14 May 2024 at 7:21am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Filtering in Calendar Control
Posted By: clivet
Subject: Filtering in Calendar Control
Date Posted: 15 June 2012 at 2:48pm
Can I do a filtering of the events to be displayed on the calendar control programmatically? I would like to provide a combo box for user to select the location and only events in the selected location are displayed. How can I do that in VBA? I am using Access 2010. Thanks.



Replies:
Posted By: SuperMario
Date Posted: 18 June 2012 at 8:28am
To filter you can use the PrePopulate event combined with something like CustomProperties as a filter.

Here is one way to filter events. It is a very basic sample using PrePopulate.

This sample assumes you have a custom property called "Name" for your events, and some global variable named strName that holds the name of the user you want to view. The sample below will see if the event has a property with "name", if it doesn't, then it checks to see if the name is equal to strName, if it's not, it will hide it (this only hides the event, not remove it from the data source).

You can use Prepopulate event to hide some events in the Calendar display. 

Private Sub CalendarControl_PrePopulate(ByVal ViewGroup As XtremeCalendarControl.CalendarViewGroup, ByVal Events As XtremeCalendarControl.CalendarEvents)

    If Events.Count > 0 Then
        Dim i As Long
        For i = Events.Count - 1 To 0 Step -1
            If Not Events(i).CustomProperties("name") = "" Then
                If Not Events(i).CustomProperties("name") = strName Then
                    Events.Remove i
                End If
            End If
        Next
    End If
End Sub

Here is another version:


This assumes you have some BOOL that specifies when filtering is enabled (bFilterMode). Also assumes your filter text is stored in a global variable (sFilterText)

The sample simply compares the Subject of the event to some text, if they match, then the event will be displayed, if they don't match, it is not displayed. This is only visual, no data is removed from the database.

Obviously you can improve on the compare, the following sample assumes an exact match.

Private Sub CalendarControl_PrePopulate(ByVal ViewGroup As XtremeCalendarControl.CalendarViewGroup, ByVal Events As XtremeCalendarControl.CalendarEvents)

 Dim pEvent As CalendarEvent
 Dim x As Integer
 x = 0
  
 For Each pEvent In Events
  If bFilterMode Then
   If pEvent.Subject <> sFilterText Then
    Events.Remove x
   End If
   x = x + 1
  End If
 Next
  
End Sub

Hope this helps


Posted By: rahulcjain
Date Posted: 22 October 2012 at 10:15am
Hi how do i retrieve list of upcoming events report of the calendar.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net