ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / Developing an application or website / Controls, windows and pages / Controls: Available types / Scheduler control
  • Overview
  • Manipulating Scheduler controls programmatically
  • Adding a resource
  • Adding an appointment
  • Populating a Scheduler control with the data from an HFSQL data file
  • Retrieving a list of appointments
  • Displaying the schedule from a specific resource or from a specific date
  • Deleting an appointment
  • Deleting a resource
  • Modifying the control display options
  • Handling an appointment programmatically
  • Using the context menu (AAF)
  • Advanced use of events associated with the Scheduler control
  • Advanced use of events with procedures
  • Management of public holidays
  • Properties specific to Scheduler controls
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Overview
A Scheduler control can be:
To manipulate a Scheduler control through programming, WINDEV and WEBDEV propose the SchedulerXXX functions.
This help page explains how to programmatically manipulate Scheduler controls. The following example is used to store appointments in an HFSQL database.
Manipulating Scheduler controls programmatically

Adding a resource

Adding a resource into a Scheduler control is performed by SchedulerAddResource. This resource can correspond to a person, a room, ...
Example:
// Adds resources into a Scheduler control 
SchedulerAddResource(SCH_Schedule1, "Florence" + gStoredValue("FL"))
SchedulerAddResource(SCH_Schedule1, "Emma" + gStoredValue("EM"))
SchedulerAddResource(SCH_Schedule1, "Fred" + gStoredValue("FR"))

In this example, gStoredValue is used to propose a displayed resource ("Florence", for example) and a resource handled through programming ("FL", for example).
WINDEVAndroidiPhone/iPad Note: Use SchedulerAddResource to insert an image in the resource title.

Adding an appointment

Adding an appointment into a Scheduler control is performed by SchedulerAddAppointment. This function accepts two syntaxes:
  • syntax for specifying appointment features: title, description, ...
    Example:
    // Adds a 1-hour appointment for tonight 
    MyResource is string
    MyTitle is string
    StartAPT is DateTime
    
    MyResource = "Vince"
    MyTitle = "Sales meeting"
    StartAPT = DateSys() + "17000000"
    
    SchedulerAddAppointment(SCH_Schedule, MyResource, MyTitle, StartAPT)
  • syntax that handles a variable of type Appointment.
    Example:
    // Declares an Appointment variable 
    MyAppointment is Appointment
    
    // Fills the appointment
    MyAppointment.Title = "Sales meeting"
    MyAppointment.Content = "Meeting to discuss the weekly objectives."
    MyAppointment.StartDate = "201003220845"
    MyAppointment.EndDate = "201003221230"
    MyAppointment.Category = "Sales"
    MyAppointment.ID = 1
    
    // Adds the appointment into the control
    SchedulerAddAppointment(SCH_Schedule, MyAppointment)

The BackgroundColor property of the Appointment variable is used to define a display color for an appointment. If no background color is defined, the Scheduler control will automatically use the color associated with the category of the appointment.

Populating a Scheduler control with the data from an HFSQL data file

The records are stored in an HFSQL data file. The initial fill of the Scheduler control can be done by browsing the data file via the FOR EACH syntax and by adding each appointment via SchedulerAddAppointment.
// Appointment variable 
MyAppointment is Appointment

// Browse the appointments stored in database
FOR EACH APT 
	// Fills the information of the variable
	MyAppointment.Title = APT.Title
	MyAppointment.Content = APT.Content
	MyAppointment.StartDate = APT.StartDate
	MyAppointment.EndDate = APT.EndDate
	MyAppointment.Category = APT.Category
	MyAppointment.ID = APT.APTID

	// Adds the appointment into the Scheduler control
	SchedulerAddAppointment(SCH_MySchedule, MyAppointment)
END

Retrieving a list of appointments

SchedulerListAppointment is used to retrieve:
  • the list of all the appointments found in the Scheduler control.
    For example:
    // Array containing a list of Appointment 
    arrAppointmentList is array of Appointment
    
    // Lists of appointments 
    arrAppointmentList = SchedulerListAppointment(SCH_MySchedule)
  • the list of appointments for a resource included between two dates.
    For example:
    // List of appointments for January 2020
    arrAppointmentList is array of Appointment
    
    // Lists of appointments
    arrAppointmentList = SchedulerListAppointment(SCH_MyScheduler, MyResource, ...
    			"20200101", "20200131")
  • the appointment currently selected or hovered.
    For example:
    // Selected appointment
    arrAppointmentList is array of Appointment
    
    arrAppointmentList = SchedulerListAppointment(SCH_MyScheduler, schAptSelected)

Displaying the schedule from a specific resource or from a specific date

To display the Scheduler control from:
  • a specific resource, use SchedulerPositionResource.
    For example:
    SchedulerAddAppointment(SCH_NoName1, "ABC room", "APT 1", ...
    		DateSys() + "14000", DateSys() + "16000")
    SchedulerPositionResource(SCH_NoName1, "ABC room")
  • from a specific date, use SchedulerPositionDateTime.
    For example:
    // Positions the schedule on today's date
    SchedulerPositionDateTime(SCH_Schedule, Today())

Deleting an appointment

SchedulerDeleteAppointment is used to delete:
  • the appointment selected in the control.
  • a specific appointment.
// Deletes the first appointment
SchedulerDeleteAppointment(SCH_Schedule, 1)

Deleting a resource

SchedulerDeleteResource is used to delete a resource from the Scheduler control.
// Deletes one of the resources
ResDel is boolean
ResDel = SchedulerDeleteResource(SCH_Schedule1, "Flo") 
IF ResDel = True THEN
	Info("Resource deleted")
END

SchedulerDeleteAll deletes all the appointments from the Scheduler control as well as all its resources.

Modifying the control display options

The current display of a Scheduler control can be modified via the following functions:
Handling an appointment programmatically
You have the ability to handle an appointment through programming:
  • by using the index of the appointment to modify.
  • by pointing by reference on the appointment to modify.
1. Using the index
Each time an appointment is added to a schedule, SchedulerAddAppointment returns an index. This index represents the added appointment. This index can be used to handle the appointment directly.
Example:
APTNum is int
APTNum = 5

// Change the title displayed on the appointment #5
SCH_ROOM[APTNum].Title = "Blue room"
2. Using a reference
To manipulate an appointment, use the <- operator to associate the appointment found in the Scheduler control with the Appointment variable. A modification performed on the variable will be automatically applied to the control.
Example:
TO is Appointment
TO <- SCH_Room[APTNum]
TO.Title = "New title"
Using the context menu (AAF)
WINDEVWindows The Scheduler control is associated with a context menu (AAF). The context menu of the Scheduler control is used to:
  • change the control display mode,
  • add, modify or delete an appointment.
To save the operations performed, you must use the events of the Scheduler control.
In the corresponding event, simply retrieve the appointment currently used and perform the corresponding process.
Example To store an appointment added by the user via the context menu in an RDV data file, simply enter the following in the "Enter appointment" event:
PROCEDURE Edit(aptEdited is Appointment)

// Store the data
APT.Title = aptEdited.Title
APT.StartDate = aptEdited.StartDate
APT.EndDate = aptEdited.EndDate
...
HAdd(APT)
The same type of code can be implemented for the different events of the Scheduler control. Indeed, for each control event that handles an appointment, a procedure has been automatically declared by the Scheduler control.
These procedures receive a variable of type Appointment as parameter.
Advanced use of events associated with the Scheduler control

Advanced use of events with procedures

You can allow the user to define more precisely the characteristics of his appointment during an addition or a modification. To do so, create a window or a page with the information to fill.
In the code, simply open the window or the page in the "Entry in edit in an appointment" event. To lock the direct input, the event must return False.
WINDEVWindows This principle can be applied to all the events called by the context menu of the Scheduler control.
Example: Opening an appointment entry window.
PROCEDURE Edit(aptEdited is Appointment)

// Opens the window for entering an appointment 
// with the selected appointment (in Creation or Modification mode)
Open(WIN_InputAPT_HFSQL, aptEdited)

// Returns False to lock the direct input in the Scheduler control
RETURN False
Management of public holidays
Public holidays can be set programmatically. Several WLanguage functions (starting with BankHolidayXXX) are available.
To define the public holidays displayed in Organizer, Scheduler and Calendar controls, use BankHolidayAdd. This function allows you to define the list of public holidays to be used. This function allows you to customize the public holidays according to the country and local regulations. This function must be used at the beginning of the application because it has a global effect on the application.
Public holidays will be in green in the schedule.
Example:
// Suppression de tous les jours fériés
BankHolidayDeleteAll()
// Initialisation des 11 jours fériés communs aux départements français et DOM/TOM
BankHolidayAdd("0101")		// 1er Janvier
BankHolidayAdd(bhEasterMonday)	// Lundi de Pâques
BankHolidayAdd("0501")		// 1er Mai
BankHolidayAdd("0508")		// 8 Mai
BankHolidayAdd(bhAscensionDay)	// Jeudi de l'Ascension
BankHolidayAdd(bhWhitMonday)	// Lundi de Pentecôte
BankHolidayAdd("0714")		// 14 Juillet
BankHolidayAdd("0815")		// 15 Août (Assomption)
BankHolidayAdd("1101")		// Toussaint
BankHolidayAdd("1111")		// 11 Novembre
BankHolidayAdd("1225")		// Noël

// Ajout de 2 jours fériés supplémentaires pour la Moselle et l'Alsace
BankHolidayAdd("1226" + CR + bhGoodFriday)
Properties specific to Scheduler controls
The following properties are specific to Scheduler control by programming.
DayBreakHeightThe DayBreakHeight property gets and sets the height of breaks between days in a Scheduler control where days are arranged in rows, and resources are arranged in columns.
DayHeightThe DayHeight property gets and sets the height of days in a Scheduler control where days are arranged in rows, and resources are arranged in columns.
DayWidthThe DayWidth property is used to determine and change the width of days:
  • in a Scheduler control where the days are displayed by columns and the resources in rows.
  • in a Gantt Chart column.
DirectInputAPTThe DirectInputAPT property is used to determine and specify if the user can directly change the title of an appointment in a Scheduler or Organizer control.
EndDateThe property EndDate property is used to find out and modify the end date of the selected period:
  • in a Calendar control,
  • in an Organizer control.
  • in a Scheduler control.
GranularityAppointmentThe GranularityAppointment gets and changes the precision of the grid used to define appointments in Organizer or Scheduler controls. Property kept for backward compatibility.
GranularityDurationThe GranularityDuration property gets and sets the size of the grid to resize:
  • appointments in an Organizer control.
  • appointments in a Scheduler control.
  • events in a TimeLine control.
  • tasks in a Gantt Chart column.
GranularityMovementThe property GranularityDisplacement property is used to identify and modify the grid size for displacement:
  • appointments in an Organizer control.
  • appointments in a Scheduler control.
  • events in a TimeLine control.
  • tasks in a Gantt Chart column.
MaskTitleDateThe MaskTitleDate property is used to identify and change the input mask used for the title of day columns in Organizer or Scheduler controls
MovementAPTThe MovementAPT property allows you to know and specify whether users can move appointments in a Scheduler or Organizer control.
NbDayDisplayedThe property NbJourAffiché property allows you to:
  • get and change the number of days displayed in an Organizer or Scheduler control.
  • get the number of days displayed in a Gantt Chart control in a report.
Num1stDayOfTheWeekThe Num1stDayOfTheWeek property gets and sets the 1st day of the week displayed in:
  • a Calendar control.
  • an Organizer control.
  • a Scheduler control.
  • an Edit control in Date format with Calendar.
PeriodSelectionThe PeriodSelection property is used to determine and specify if the user can select a time period in an Scheduler or Organizer control.
ResourceThe Resource property is used to:
  • find out the resources visible in a Scheduler control.
  • find out the resource of the Scheduler control that corresponds to the specified index.
ResourceHeightThe ResourceHeight property gets and sets the height of resources in a Scheduler control where resources are arranged in rows.
ResourceWidthThe ResourceWidth property gets and sets the width of resources in a Scheduler control where resources are arranged in columns.
SelectedResourceThe SelectedResource property returns the name of the resource that corresponds to the user's selection in a Scheduler control.
StartDateThe StartDate property is used to determine and change the start date of the selected time period:
  • in a Calendar control.
  • in an Organizer control.
  • in a Scheduler control.
WorkingHourEndThe WorkingHourEnd property is used to identify and change the end time of working hours used:
  • by an Organizer control.
  • by a Scheduler control.
  • by a Gantt Chart column (in a Table or TreeView Table control).
WorkingHourStartThe WorkingHourStart property gets and sets the start time of working hours used:
  • by an Organizer control.
  • by a Scheduler control.
  • by a Gantt Chart column (in a Table or TreeView Table control).
For a complete list of WLanguage properties that can be used with Scheduler controls, see Scheduler control properties.
Minimum version required
  • Version 16
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 12/06/2024

Send a report | Local help