|
|
|
|
|
- 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
To manipulate a Gantt Chart control through programming, WINDEV proposes: 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, name the fields with the same names as 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)
Note: By default, the link created is of type "End to Start".. The type of created link can be configured in the GanttLink variable or in GanttAddLink. The available links are: - Link type "Start to Start": The successor task cannot start before the predecessor task has started.
- Link type "Start to Finish": The destination task cannot finish before the source task has started (rare case).
- End-to-start link (default case): The destination task cannot start before the source task has finished..
- Type of link "Finish to Finish": The destination task cannot finish before the source task is finished.
By default, Gantt chart columns are set up to automatically reorganize tasks according to their links: if the user moves a task in time, all tasks dependent on it are automatically moved.. To disable this parameter and to freely organize the tasks: - Open the control description window.
- On the "Details" tab, uncheck "Reorganizar las otras tareas cuando el usuario hace cambios".
- 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 task(s).", ...
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 recovered task: %1.", tabListe[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 context 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 save a task added by the user via the context menu in a "Task" data file, simply enter in the "Task entry" event: 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 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: PROCEDURE EnterInInput(gtEdited is GanttTask)
Open(WIN_TaskInput, gtEdited)
RETURN 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:
BankHolidayDeleteAll()
BankHolidayAdd("0101")
BankHolidayAdd(bhEasterMonday)
BankHolidayAdd("0501")
BankHolidayAdd("0508")
BankHolidayAdd(bhAscensionDay)
BankHolidayAdd(bhWhitMonday)
BankHolidayAdd("0714")
BankHolidayAdd("0815")
BankHolidayAdd("1101")
BankHolidayAdd("1111")
BankHolidayAdd("1225")
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:
GanttWorkingHour(COL_Gantt, 2, "0930", "1200", "1300", "1830")
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 specific to programmed Gantt chart management.
| | AutomaticReorganization | The AutomaticReorganization property gets and sets the automatic reorganization mode for the tasks in a "Gantt Chart" column. | DisplayLink | La propiedad DisplayLink obtiene y establece el modo de visualización de los enlaces en una columna de tipo Diagrama de Gantt. | MovementTask | La propiedad MovementTask permite conocer y modificar la forma en que los usuarios mueven las tareas en una columna del diagrama de Gantt. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|