Dummy Tasks with gantt.posFromDate


#1

I am trying to create temporary task bar to overlap other task on hover or click.
The challenge we have is to find out the width of the duration/endDate.

We use gantt.posFromDate(new Date()), but how can we find the width according to
it’s endDate?

Appreciate tip on this issue


#2

Hello,
You can use the getTaskPosition method to find the sizes of a dummy task by using only the dates and a task object (you need any task to obtain the height and top parameters):
https://docs.dhtmlx.com/gantt/api__gantt_gettaskposition.html
Here is an example of how it works:
http://snippet.dhtmlx.com/5/88b3a3fa7


#3

Thank you for tip. I have ordinary task, but want to create a dummy task box that retrieve optional date values and show as separate bar. Do I need to create a task object each time I hover or click ordinary task, then create optional “dummy” task, for then to delete same? Am not sure how to accomplish this.


#4

Hello,
The getTaskPosition method requires the task object to get the vertical and horizontal position of the sizes. And anyway, you will need to draw a dummy task bar in the timeline, isn’t it? So, you can choose a task row and use the task object from that row. Otherwise, you just need to take the first task in the chart, if you only need horizontal sizes.

If you hover an ordinary task and want to show a dummy task only during that time, it would be easier to do that by using the addTaskLayer feature:
https://docs.dhtmlx.com/gantt/api__gantt_addtasklayer.html
Here is an example of how it can be implemented:
http://snippet.dhtmlx.com/5/854c488c7