Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

206
Views
Arrastrar tareas dentro de la fecha de finalización de la tarea de origen DHTMLX Gantt

personalizo un gantt DHTMLX con mi db. Para Datos, solo elijo id, texto, fecha de inicio, duración y fecha de finalización. Para los enlaces, elijo id, origen, destino y tipo, todos los tipos son 0.

He hecho la tarea de arrastrar junto con su tarea dependiente, moviendo la tarea manualmente. Mover descendientes sincrónicamente con la tarea principal (enlace: https://docs.dhtmlx.com/gantt/desktop__dragging_dependent_tasks.html#movingtasksmanually )

He agregado a mi gantt.aspx este código:

 gantt.eachSuccessor = function (callback, root) { if (!this.isTaskExists(root)) return; // remember tasks we've already iterated in order to avoid infinite loops var traversedTasks = arguments[2] || {}; if (traversedTasks[root]) return; traversedTasks[root] = true; var rootTask = this.getTask(root); var links = rootTask.$source; if (links) { for (var i = 0; i < links.length; i++) { var link = this.getLink(links[i]); if (this.isTaskExists(link.target) && !traversedTasks[link.target]) { callback.call(this, this.getTask(link.target)); // iterate the whole branch, not only first-level dependencies this.eachSuccessor(callback, link.target, traversedTasks); } } } }; gantt.attachEvent("onTaskDrag", function (id, mode, task, original) { var modes = gantt.config.drag_mode; if (mode == modes.move) { var diff = task.start_date - original.start_date; gantt.eachSuccessor(function (child) { child.start_date = new Date(+child.start_date + diff); child.end_date = new Date(+child.end_date + diff); gantt.refreshTask(child.id, true); }, id); } return true; }); gantt.attachEvent("onAfterTaskDrag", function (id, mode, e) { var modes = gantt.config.drag_mode; if (mode == modes.move) { gantt.eachSuccessor(function (child) { child.start_date = gantt.roundDate(child.start_date); child.end_date = gantt.calculateEndDate(child.start_date, child.duration); gantt.updateTask(child.id); }, id); } });``` Now i have to add the constrain that a child(target) task can't move before the end date of father(source). I have to add a Left limit for all tasks, but i have no idea how to do, because i haven't “parent” on my data details.
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

En el controlador de eventos onTaskDrag , tiene el objeto de la task que está arrastrando. Para las tareas relacionadas, existe la variable child , aunque las tareas no son necesariamente las secundarias de la tarea arrastrada. Por lo tanto, puede obtener la fecha de finalización de la tarea que está arrastrando desde el objeto de la task . En el controlador de eventos onAfterTaskDrag , no tiene el objeto de la task , pero puede obtenerlo mediante el gantt.getTask(id) :

 gantt.attachEvent("onAfterTaskDrag", function (id, mode, e) { var task = gantt.getTask(id); var modes = gantt.config.drag_mode; if (mode == modes.move) { gantt.eachSuccessor(function (child) { child.start_date = gantt.roundDate(child.start_date); child.end_date = gantt.calculateEndDate(child.start_date, child.duration); gantt.updateTask(child.id); }, id); } });

https://docs.dhtmlx.com/gantt/api__gantt_gettask.html

También puede utilizar la función de programación automática: https://docs.dhtmlx.com/gantt/desktop__auto_scheduling.html

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!