Easier way to prevent task types from activating

Hi,

I have created a custom task type, say call group.

Now, before I created this new group type, I have a lot of assumption over the data available. Meaning to say,
I would assume that there is start_date, end_date, and so on.

However, with this group type, it is quite similar to project where it does not start_date, end_date and so on.

So in many on my events triggers such as

gantt.attachEvent('onQuickInfo` function(taskId) {
  const task = gantt.getTask(taskId);
  const start = task.start_date;
  const end = task.end_date;
}

or declaring the templates.

gantt.templates.quick_info_content = function(start, end, task){ 
       return task.start_date;
};

With new requirements, new type is added, and my current solution is to do a prevent trigger such as:

gantt.attachEvent('onQuickInfo` function(taskId) {
  if (task.type === gantt.config.types.group) return;
  const task = gantt.getTask(taskId);
  const start = task.start_date;
  const end = task.end_date;
}
gantt.templates.quick_info_content = function(start, end, task){ 
  if (task.type === gantt.config.types.group) return;
  return task.start_date;
};

And this (checking task type) is spreading over and across multiple places all over the project. I am wondering if there is a better way to achieve the same by setting it at a global function or something.

Note: the code may not be accurate, it’s just a concept.

Thanks.

Hello Joseph,
Unfortunately, your idea and question are not clear to me.
You can use a function to check the task type and return the values you need. But you need to use that function in the event handlers and templates.
In the following snippet, you can see that the function works the same way as the commented code.
http://snippet.dhtmlx.com/b67d04520
If you need something different, please give me a more detailed description of your idea or show it on a screenshot.

Hi @ramil,

That is precisely the issue.

I need to perform the check at every event handlers and templates, so I assume there is no way to perform a overwrite at some global setting which gets applies to all event handler and templates to skip the processing for certain type.

Basically the idea to skip any processing if the type is group (for example). This way I don’t need to check in every single events, templates, and so on.

Let me know if this is still not clear to you.

Thanks.

Hello Joseph,
Thank you for the clarification.
It is not possible to overwrite all event handlers with one function. Gantt has some templates that are applied in different places, for example:
https://docs.dhtmlx.com/gantt/api__gantt_task_unscheduled_time_template.html
But there is no built-in group check. You need to use a function to check the group type and apply your code in the event handlers and templates.

Hi @ramil,

I’m currently using that (method) to perform a check on templates and event handlers now.

Thought I try my luck.

Thanks anyway.