Add tooltip on addTaskLayer


It’s possible to add tooltip on addTaskLayer? (Using dhtmlxgantt tooltip ext)

gantt.addTaskLayer(function draw(task) {
var el = document.createElement(‘div’);
var sizes = gantt.getTaskPosition(task,; = sizes.left + ‘px’; = + ‘px’;
el.setAttribute(‘title’, gantt.templates.task_date(; // Here add tooltip, but want to use dhtmlxgantt tooltip
return el;
return false;


Update 2019-08-06

Since this question is fairly popular, here is the update.
Tooltips has been updated in v6.1 and now it’s possible to add tooltips to custom elements and task layers using the public API:

gantt.attachEvent("onGanttReady", function () {
  gantt.templates.tooltip_text = function(start, end, task){
    return "<b>Task:</b> " + task.text + "<br/><b>Start date:</b> "
      + gantt.templates.tooltip_date_format(start) 
      + "<br/><b>End date:</b> " 
      + gantt.templates.tooltip_date_format(end);
  var tooltips = gantt.ext.tooltips;
    selector: ".deadline",
    html: function (event, node) {
      var taskId = node.getAttribute(gantt.config.task_attribute);
      var task = gantt.getTask(taskId);
      return "<b>Task:</b> " + task.text + "<br/><b>Deadline:</b> "
         + gantt.templates.tooltip_date_format(task.deadline) ;


Previous reply:

The simplest approach is to add task id attribute to the custom element:
If you do so, it will trigger the same onhover and onclick handlers as the task bar, i.e. your custom element will show the same tooltip on mouseover and you’ll be able to open lightbox by double clicking the element.
Here is an example

But it becomes more difficult if you want different tooltip content for custom elements. In that case you’ll probably need to override some internal methods in order to pass an additional info into tooltip_text template, e.g. like shown in this example


Thanx, Aliaksandr.


In your example I see a problem that I also having and I’m not finding a solution.

When you try to add a new task deadline dropdowns are gone and always is set to null without no possibility to change it. Any idea?


What are happeging with dates? My previous post is from minutes before.


If quote a message appear with a fake datetime.


How to show tooltip for task grid column(particular to one column) , I am using 4.1.19 version of library.

I rendered cell content with HTML string and I need to show some custom tooltip on the clock icon


Hello Vittal,
In the 4.1 version, there is a simple tooltip API. The functionality of adding tooltips for custom HTML elements was added in the 6.1 version:

So, you can use the basic popup message to show something like the tooltip:
Here is an example of how it might be implemented:

If you need something more similar to the tooltip, you need to implement a custom solution.