Gantt.templates.date_grid VS gantt.templates.grid_date_format

Could you please shed some light on the difference between these two templates:

gantt.templates.date_grid

and

gantt.templates.grid_date_format

Thanks in advance.

Hello Nikolai,

  • gantt.templates.grid_date_format(date, column) is a simple date formatting function that converts a date object to a string. By default, it’s automatically created from the gantt.config.date_grid configuration string.
  • gantt.templates.date_grid(date, task, column) is a higher-level template that determines the content of date columns in the grid. By default, it calls gantt.templates.grid_date_format internally, but also adds additional logic (like handling unscheduled tasks). In the default implementation, it checks for unscheduled tasks and handles them differently before calling grid_date_format.

So, you can override grid_date_format if you just need to change the date formatting for all date columns. Or you can override the date_grid template if you need task-specific logic when displaying dates in grid columns and you need to have access to the full task object.

In this example, the grid_date_format template is used to make end_date inclusive when displaying it in the grid column.

And in this snippet, just for example, we use the date_grid template to to access the full task object and display dates in the necessary format based on some properties.

Best regards,
Valeria Ivashkevich
DHTMLX Support Engineer