|
|
|
|
|
- Overview
- Manipulating Gantt Chart controls programmatically
- Adding a task
- Adding a link
- Organizing the tasks
- Filling a Gantt Chart column with the data found in an HFSQL data file
- Retrieving a list of tasks
- Displaying the Gantt chart from a specific date
- Deleting a task
- Deleting a link
- Using the context menu (AAF)
- Advanced use of events associated with a Gantt Chart column
- Advanced use of events with procedures
- Managing the bank holidays, the holidays and the working hours
- Management of public holidays
- Managing the holidays
- Managing the working hours
- Properties specific to the Gantt Chart columns
Manipulating Gantt Chart controls programmatically
WINDEV includes the following elements to manipulate Gantt Chart controls programmatically: This help page explains how to programmatically manipulate Gantt Chart controls: Manipulating Gantt Chart controls programmatically To add a task into a Gantt Chart column: - Define and fill a GanttTask variable.
- 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 line of code: //Updates the variable with the data of the items in the data file FileToMemory(NewTask, TaskForGantt)
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 a variable of type GanttLink.
// Create a link via a GanttLink variable Link is GanttLink Link.SourceID = "T1" Link.DestinationID = "T2" GanttAddLink(COL_Gantt, Link)
Remark: The created link is an "End to Start" link by default. The type of created link can be configured in the GanttLink variable or in GanttAddLink. The available links are: - "Start to Start" link: The target task can only start if the source task is 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 target 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.
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: - Open the control description window.
- In the "Details" tab, uncheck "Reorganize other tasks when the user makes changes".
- Use GanttOrganizeTask to force a selective reorganization of tasks.
Filling a Gantt Chart column with the data found in an HFSQL data file The records are stored in an HFSQL data 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
Retrieving a list of tasks - the list of all the tasks found in the Gantt Chart column:
arrList is array of GanttTask
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:
arrList is array of GanttTask
arrList = GanttListTask(COL_Gantt, ganttSelectedTask)
InfoBuild("The retrieved task: %1.", arrList[1].Title)
Displaying the Gantt chart from a specific date GanttPositionDateTime(COL_Gantt, DateSys())
Deleting a task For example: // "Delete" button IF YesNo("Do you want to delete this task") THEN GanttDeleteTask(COL_Gantt1) END
Deleting 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 context menu (AAF) The Gantt Chart Column control is associated with a context 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 events of the column. In the corresponding event, simply retrieve the task or link currently used and perform the corresponding process. Example: To store a task added by the user via the context menu in a "Task" data file, simply enter the following code in the "Exit from task input" event: PROCÉDURE 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 events of the Gantt Chart column. Indeed, for each event in the control that handles a task or link, a procedure has been automatically declared by the Column control. These procedures receive a GanttTask or GanttLink variable affected by the event as parameter. Advanced use of events associated with a Gantt Chart column Advanced use of events with procedures 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, simply open the window in the "Enter the task in input" event. To lock the direct input via the context menu of the column, the event must return False. This principle can be applied to all the events called by the context menu of the column. Example: PROCÉDURE 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 Management of public holidays Public holidays can be set programmatically. 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 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. The bank holidays will be colored in green in the Gantt chart. Example: // Delete all public holidays BankHolidayDeleteAll() // Initialize the 11 public holidays common to the French regions and 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 public 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. 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") Remarks: - 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 through programming.
| | AutomaticReorganization | The AutomaticReorganization property is used to get and change the automatic reorganization mode for the tasks in a "Gantt Chart" column. | DisplayLink | The DisplayLink property gets and sets the display mode of the links in a Gantt Chart column. | MovementTask | The MovementTask property allows you to know and modify the way users move tasks in a Gantt Chart column. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|