PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

  • Overview
  • Handling the Gantt Chart control by programming
  • Add a task
  • Add a link
  • Organize the tasks
  • Fill a Gantt Chart column with the data found in a HFSQL data file
  • Retrieve a list of tasks
  • Display the Gantt chart from a specific date
  • Delete a task
  • Delete a link
  • Using the popup menu (AAF)
  • Advanced use of the processes associated with a Gantt Chart column
  • Advanced use of processes with procedure
  • Managing the bank holidays, the holidays and the working hours
  • Managing bank holidays
  • Managing the holidays
  • Managing the working hours
  • Properties specific to the Gantt Chart columns
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Handling a Gantt Chart control by programming
Overview
To handle a Gantt Chart control by programming, WINDEV proposes:
This help page explains how to handle a Gantt Chart control by programming:
Handling the Gantt Chart control by programming

Add a task

To add a task into a Gantt Chart column:
  1. Define and fill a GanttTask variable.
  2. Add the task with GanttAddTask.
Example:
NewTask is GanttTask

// Configures the task
NewTask..ID = GetIdentifier()
NewTask..Row = 1
NewTask..Progress = 50
NewTask..StartDate = Today()
NewTask..DurationInDay = 1
NewTask..Title = "New task"

// Adds the task
GanttAddTask(COL_Gantt, NewTask)
Tip: If the tasks are stored in a data file, the items must be named like the members of the GanttTask variable. Then, you will have the ability to use FileToMemory to fill the variable in a single code line:
// Fills the variable from the file items
FileToMemory(NewTask, TaskForGantt)

Add a link

To add a link between two tasks found in a Gantt Chart column, all you have to do is call GanttAddLink. This function accepts two syntaxes:
  • syntax used to link 2 tasks identified by their identifier:
    t1 is GanttTask
    t1..ID = "T1"
    t2 is GanttTask
    t2..ID = "T2"
    GanttAddLink(COL_Gantt, t1, t2)
  • syntax that handles an GanttLink variable.
    // Create a link via a GanttLink variable
    Link is GanttLink
    Link..SourceID = "T1"
    Link..DestinationID = "T2"
    GanttAddLink(COL_Gantt, Link)
Note: The created link is an "End to Start" link by default.
Versions 190044 and later
The type of created link can be configured in the GanttLink variable or in GanttAddLink. The available links are:
  • "Start to Start" link: The destination task cannot start as long as the source task is not started.
  • "Start to End" link: The destination task cannot end as long as the source task is not started (rare case).
  • "End to Start" link (default case): The destination task cannot start as long as the source task is not ended.
  • "End to End" link: The destination task cannot end as long as the source task is not ended.
New in version 190044
The type of created link can be configured in the GanttLink variable or in GanttAddLink. The available links are:
  • "Start to Start" link: The destination task cannot start as long as the source task is not started.
  • "Start to End" link: The destination task cannot end as long as the source task is not started (rare case).
  • "End to Start" link (default case): The destination task cannot start as long as the source task is not ended.
  • "End to End" link: The destination task cannot end as long as the source task is not ended.
The type of created link can be configured in the GanttLink variable or in GanttAddLink. The available links are:
  • "Start to Start" link: The destination task cannot start as long as the source task is not started.
  • "Start to End" link: The destination task cannot end as long as the source task is not started (rare case).
  • "End to Start" link (default case): The destination task cannot start as long as the source task is not ended.
  • "End to End" link: The destination task cannot end as long as the source task is not ended.

Organize the tasks

By default, the Gantt Chart columns are configured to automatically reorganize the tasks according to their links: if the user moves a task in time, all the tasks that depend on this task will be automatically moved.
To disable this parameter and to freely organize the tasks:
  1. Display the description window of control.
  2. In the "Details" tab, uncheck "Re-organizing the other tasks after user modification".
  3. Use GanttOrganizeTask to force a selective reorganization of tasks.

Fill a Gantt Chart column with the data found in a HFSQL data file

The records are stored in a HFSQL file. The initial fill of the Gantt Chart control can be done by browsing the data file via the FOR EACH syntax and by adding each task via GanttAddTask.
// GanttTask variable
MyTask is GanttTask

// Browse the tasks stored in database
FOR EACH Task
// Fills the information of the variable
MyTask..ID = Task.Identifier
MyTask..Progress = Task.Progress
MyTask..StartDate = Task.Date
MyTask..DurationInDay = Task.TaskDuration
MyTask..Title = Task.Title
// Adds the task
GanttAddTask(COL_Gantt, MyTask)
END

Retrieve a list of tasks

GanttListTask is used to retrieve:
  • the list of all the tasks found in the Gantt Chart column:
    // Lists all the tasks
    arrList is array of GanttTask

    // Retrieves the list of tasks
    arrList = GanttListTask(COL_Gantt)

    InfoBuild("The tasks have been retrieved: the array contains %1 tasks.", ...
    arrList..Occurrence)
  • the list of tasks included between two dates:
    // Lists the tasks from today's date
    arrList is array of GanttTask

    // Retrieves the list of tasks
    arrList = GanttListTask(COL_Gantt, DateSys())
  • the task that is currently selected or hovered:
    // Retrieves the selected task
    arrList is array of GanttTask

    // Retrieves the list of tasks
    arrList = GanttListTask(COL_Gantt, ganttSelectedTask)

    InfoBuild("The retrieved task: %1.", arrList[1]..Title)

Display the Gantt chart from a specific date

To display the Gantt chart from a specific date and time, use GanttDateTimePosition.
GanttDateTimePosition(COL_Gantt, DateSys())

Delete a task

GanttDeleteTask is used to delete a task.
For example:
// "Delete" button
IF YesNo("Do you want to delete this task") THEN
GanttDeleteTask(COL_Gantt1)
END

Delete a link

GanttDeleteLink is used to delete a link.
For example:
// Deletes the links from the T2 task
GanttDeleteLink(COL_Gantt, "T2")
GanttDeleteAll is used to delete all the tasks and all the links from a Gantt Chart column.
Using the popup menu (AAF)
The Gantt Chart Column control is associated with a popup menu (AAF). The popup menu allows you to:
  • Add, delete or modify a task.
  • Link the selected task to a prerequisite task.
  • Delete all the prerequisites from a task.
  • Print the content of the Gantt chart. This option is available only if a "Gantt Chart" report was created.
To save the operations performed, you must use the processes of the column.
In the relevant process, all you have to do is retrieve the task or link currently used and perform the corresponding process.
Example: To store a task added by the user via the popup menu in a "Task" data file, all you have to do is enter in the "Enter in task input" process:
PROCEDURE EnterInInput(gtEdited is GanttTask)

// Store the data
Task.Title = gtEdited..Title
Task.StartDate = gtEdited..StartDate
Task.EndDate = gtEdited..EndDate
...
HAdd(Task)
The same type of code can be implemented for the different processes of the Gantt Chart column. Indeed, for each process of the control that handles a task or a link, a procedure was automatically declared by the Column control.
These procedures receive in parameter a GanttTask or GanttLink variable affected by the process.
Advanced use of the processes associated with a Gantt Chart column

Advanced use of processes with procedure

You can also allow the user to define more precisely the characteristics of his task during an addition or a modification.
To do so, create a window with the information to specify.
In the code, all you have to do is open the window in the "Enter the task in input" process. To lock the direct input via the popup menu of the column, the process must return False.
This principle can be applied to all the processes called by the popup menu of the column.
Example:
PROCEDURE EnterInInput(gtEdited is GanttTask)

// Opens the window for task input
// with the selected task (in Creation or Modification mode)
Open(WIN_TaskInput, gtEdited)

// Returns False to lock the direct input in the column
RESULT False
Managing the bank holidays, the holidays and the working hours

Managing bank holidays

The bank holidays are managed by programming. Several WLanguage functions (starting with BankHolidayXXX) are available.
To define the bank holidays displayed in the Organizer, Scheduler, Calendar and Gantt Chart Column controls, you must use BankHolidayAdd. This function allows you to define the list of bank holidays that will be used. This function allows you to customize the bank holidays according to the country and to the local regulations. This function must be used at the beginning of the application because it has a global effect on the application.
The bank holidays will be colored in green in the Gantt chart.
Example:
// Delete all bank holidays
BankHolidayDeleteAll()
// Initialize the 11 bank holidays common to the French regions and to the French territories
BankHolidayAdd("0101") // 1st of January
BankHolidayAdd(bhEasterMonday) // Easter Monday
BankHolidayAdd("0501") // 1st of May
BankHolidayAdd("0508") // 8th of May
BankHolidayAdd(bhAscensionDay) // Ascension day
BankHolidayAdd(bhWhitMonday) // Whit Monday
BankHolidayAdd("0714") // 14th of July
BankHolidayAdd("0815") // 15th of August (Assumption)
BankHolidayAdd("1101") // All Saints' Day
BankHolidayAdd("1111") // 11th of November
BankHolidayAdd("1225") // Christmas

// Add 2 additional bank holidays for the regions of Moselle and Alsace
BankHolidayAdd("1226" + CR + bhGoodFriday)

Managing the holidays

To manage the holidays in a Gantt chart for a given row, all you have to do is use GanttAddHoliday. In this case:
  • The new holiday period is considered as being a non-working period for the row.
  • The duration of the tasks is adjusted according to the specified holiday period.
Example:
// Holidays for row 4
GanttAddHoliday(COL_Gantt, 4, "20140204", "20140204")

Managing the working hours

By default, the working hours are defined when describing the Gantt Chart control in the window editor. These working hours can be modified for the entire control with ..WorkingHourStart and ..WorkingHourEnd.
GanttWorkingHour is used to customize the working hours for a given row.
Example:
// For row 2, the working hours go from 9:30 to 12:00 then from 13:00 to 18:30
GanttWorkingHour(COL_Gantt, 2, "0930", "1200", "1300", "1830")
// For row 3, the working hours go from 10:00 to 17:00
GanttWorkingHour(COL_Gantt, 3, "1000", "1700")
Notes:
  • This function affects the drawing of the Gantt chart if the hours are displayed in the Gantt chart.
  • This function affects the calculation of the task duration if the tasks are specified in hours.
Properties specific to the Gantt Chart columns
The following properties are used to manage a Gantt Chart by programming.
Versions 19 and later
AutomaticReorganization
New in version 19
AutomaticReorganization
AutomaticReorganization
..AutomaticReorganization is used to find out and modify the mode for automatic reorganization of the tasks in a "Gantt Chart" column.
Versions 19 and later
DisplayLink
New in version 19
DisplayLink
DisplayLink
..DisplayLink is used to find out and modify the display mode of the links in a Gantt Chart column.
Versions 19 and later
MovementTask
New in version 19
MovementTask
MovementTask
..MovementTask is used to to find out and modify the mode for moving tasks in a Gantt Chart column.
To find out the entire list of WLanguage properties that can be used with a Gantt Chart column, see Properties associated with the Gantt Chart columns.
Minimum required version
  • Version 19
Comments
Click [Add] to post a comment