Time Period Button

Hi,

Is it possible to create a button in lightbox to create a fixed time period task?
image
For exemple: a button that will create a 3 month task when I click on it, so I dont need to set a final date in the time period.

Thanks.

Hello,
Yes, it is possible to do that. You add a button, and in the onLightboxButton event handler you apply the function to update the values. Use gantt.getLightboxSection('time'); to get the time control section. And .getValue() with setValue() to obtain and update the values respectively.
Here is an example where you can set the duration to 90 days:
http://snippet.dhtmlx.com/28f3dfa86

And here is another example where you can increase the duration by 90 days:
http://snippet.dhtmlx.com/5c147b4ac

Just in case, I have another example, where you can create a task with the 90 days duration from the grid button:
http://snippet.dhtmlx.com/3430eb732

You can read more about the methods and the event handler in the following articles:
https://docs.dhtmlx.com/gantt/api__gantt_createtask.html
https://docs.dhtmlx.com/gantt/api__gantt_getlightboxsection.html
https://docs.dhtmlx.com/gantt/api__gantt_getlightboxvalues.html
https://docs.dhtmlx.com/gantt/api__gantt_onlightboxbutton_event.html

Thanks. :slight_smile:

Can I do the same function but with time type?


When I click the button the time period changes in 3 months.

Other question: can I use duration type and time type in same lightbox?

Thx.

Hello,
Sure, you just need to change the controls and use gantt.date.add to change the end_date:
https://docs.dhtmlx.com/gantt/api__gantt_date_other.html
Here is an example:
http://snippet.dhtmlx.com/166909d5c

Other question: can I use duration type and time type in same lightbox?

Yes, it is possible to do that. But you need to hide the start_date controls from the lightbox section:
https://docs.dhtmlx.com/gantt/desktop__lightbox_manipulations.html#makingasectionhiddenforsomeevents
Here is an example:
http://snippet.dhtmlx.com/c7e268b99