Different task creation Lightbox depending on + clicked


#1

Hi all,

in my scenarios, I have Projects at level 0 and tasks under.

I defined differents lightboxes to edit Projects and tasks.

When I clic on the + button, I always have the same lightbox Openning ( Tasks one ).

I would like to :

  • open the Project lightbox when the user clics on the “Header” + button
  • open the Task lightbox when the user clics on a “Task” + button

I can differ what + is clicked in the onBeforeLightbox event (using task.$level for example), but at this point, setting task.$rendered_type as “project” does not seem to help.

What is the correct way to tell dhtmlxgannt that I want a Project or a Task Lightbox at this point ?

Thanks for your help !


#2

Ok, finally found, here it is if it may help :

gantt.attachEvent("onBeforeLightbox", (id) => {
  var task = gantt.getTask(id);

  if(task.$level == 0){
    task.type = gantt.config.types.project;
  }
  return true;
});

#3

Hello Julien,
You can also add a custom element in the “+” button in the grid header, attach the onclick function and use the changeLightboxType method:
https://docs.dhtmlx.com/gantt/desktop__specifying_columns.html
https://docs.dhtmlx.com/gantt/api__gantt_changelightboxtype.html
The following snippet demonstrates how it works:
http://snippet.dhtmlx.com/5/e0566eb1c