Import from dhtmlxGantt#
Load a dhtmlxGantt project into Planning Engine and get the same task dates the gantt auto-scheduler would give you.
Planning Engine's scheduling step is a port of the dhtmlxGantt v2 auto-scheduling engine, and its records follow gantt's fields: startDate is gantt's start_date, constraintType is constraint_type, autoScheduling is auto_scheduling. Most of the import copies fields one to one. The steps below cover the places where a straight copy gives different dates or fails validation.
Prerequisites#
- Your gantt tasks, links, resources and assignments are parsed into your own Java records. The example uses Java records that mirror gantt's JSON fields.
- You know each task's effective calendar, as gantt resolves it.
To read gantt-named JSON straight into ProjectData, see Exchange JSON with a client. The steps below apply to the values either way.
Steps#
-
Set the scheduling config to gantt's model. Use
CalendarMode.TASKfor task calendars only, orCalendarMode.TASK_INHERITEDif gantt hasinherit_calendar: true. Copy gantt'swork_timeintouseCalendarsexplicitly. It defaults totrue, so Planning Engine schedules on calendars unless you turn it off:boolean ganttWorkTime ; // gantt `config.work_time` var config ;Set
rootIdonly when gantt's virtual root isn't0. The other auto-scheduling options (applyConstraints,gapBehavior,moveProjects,scheduleFromEnd,projectStart,useProgress) are gantt's options of the same name, in camelCase. -
Add one
CalendarDataper calendar your tasks use, and set each task'scalendarIdto its effective calendar. gantt picks that calendar in its adapter: the task's own, else its resource's, else a calendar merged from all its resources, else the parent's. Send the result, not the rules. A merged resource calendar goes in once, under its synthetic id. Don't repeat gantt's precedence or merging in your import code. -
Map each task to a
TaskData:- gantt
type: "project"becomesTaskType.SUMMARY. A summary takes bothstartDateandendDate, or neither. Drop itsduration, or strict validation rejects the task. - A
parentequal torootIdmeans "no parent". You can copy it as is. - A leaf task needs two of
startDate,endDateandduration. If you send all three, they must agree. - If your gantt event handlers cancel auto-scheduling for a task, set
autoSchedulingtofalseon it. The planner never moves it.
- gantt
-
Map gantt link
typevalues"0","1","2"and"3"toLinkType.FS,SS,FFandSF. Copylagand leavelagUnitasnull, because gantt measures lag inconfig.duration_unit. -
Convert each assignment to a slice of its task's work in
AssignmentData. Don't send gantt'smode.defaultandfixedDuration:delaybecomesoffsetanddurationstaysduration. Leave bothnullto book the whole task.fixedDates: setoffsetanddurationto the worked time its dates cover, measured from the task start.
A slice ends at the task end. gantt's
fixedDurationcan run past it. -
Solve the data with
Project#solveand write the changed fields fromresult.updatesback into gantt. The updates include summaries, which the gantt JS adapter leaves to gantt core. Apply those too, or your summary spans go stale.
The full example below imports a summary with two tasks, a milestone, two links, a part-time calendar and one default-mode assignment:
;
;
;
Keep gantt's triggers on your side#
Planning Engine has no UI triggers and no events. Your code decides when to schedule.
- Call
applyand thensolve(null, ...)wherever gantt would run auto-scheduling: after the user adds a link, drags a task, or saves the lightbox. See Editing a project. gantt.autoSchedule(id, inclusive)isSolveOptions.subtree. See Reschedule a branch.- Change sets can't add or edit calendars. If an assignment change gives a task a new merged calendar, send the whole project again with
solve(data, ...). - gantt core rewrites descendant dates when inherited calendars or effort change. Forward those date and duration edits as ordinary
TaskUpdatechanges. Planning Engine doesn't recreate gantt's effort rules.
Differences to expect#
- Strict validation rejects input that gantt coerces: duplicate ids, a dated constraint with no
constraintDate, a leaf task with fewer than two of start, end and duration, a dateless summary with no dated children. The rejection is anInputExceptionwith the field path. To get gantt's coercions with a report of each fix, see Accept messy input. TimeUnithas noweek,monthoryear, and calendars withcustomWeeksare rejected. A gantt merged calendar can containcustomWeeks, so such projects can't be imported yet.- A
Momentis a naive local date-time with no timezone and no DST. gantt's JS engine uses the host time zone, so its arithmetic follows DST. Convert dates to local wall-clock time before you build the data. result.noteslists the links, tasks and assignments the engine dropped. gantt drops them silently.- Three cases give different dates on purpose. With
projectConstraint = true, children inherit the parent's constraint. gantt's engine ignores it. WithuseProgress, a completed child of a moving summary stays in place. gantt drags it along. WithdescendantLinks = truein block mode, gantt fails with a cycle error and Planning Engine schedules the project. See Links, constraints and summaries. - Summary-to-summary links in block mode, combined with leaf links between the same summaries, can give different dates. On long chains of such links the dates grow without bound. See Error handling.
Result#
The example prints the changed fields:
3 start_date = 2026-03-05 00:00
3 end_date = 2026-03-12 00:00
1 end_date = 2026-03-12 00:00
4 start_date = 2026-03-12 00:00
4 end_date = 2026-03-12 00:00
Task 3 starts when task 2 finishes and works Monday to Thursday only, so it ends a week later. The summary 1 grows to cover it. Task 2 didn't move, so it isn't listed. To get every date on the first load, see Load all task dates.