How to add a custom icon to a task

I don’t know if this is possible or not.

In … lates.html,
is there a way to place a ‘gantt.templates.grid_open’ ( or custom icon) button on the ‘gantt.templates.grid_indent’ space of a particular task.

I want to use this button as a toggle for collapsing similar tasks to this task or not.


Hello Sun,
Yes, it is possible to do that. You just return the div element with the onclick function defined. In the function you process each task and compare task levels to determine if the task should be collapsed or not.
In the following example you can click on the gray plus button near tasks #2, #3 and #7 and the task #4 will be collapsed or expanded.
These articles may be useful for you: … plate.html

Thank you very much!
I’ll definitely make use of what you suggested.
Take care,

Hi Ramil,

Finally, I had time to get down with this case.

I have 2 questions for you.
In collapse("+item.$level+") in your code, what does “+” on both side of item.$level do? I have never seen this kind of coding before…
Could you shed some light?

2nd question is more about getting an advice from you, if you have any.
Let’s say I want to display “+” icon on Task#5 ( not on Task #2, #3, #4, #6, #7) so that I can collapse Task #6 only ( Note: at its SAME level only for its own type)
Any suggestion?



Hello Sun,
I will try to answer your questions in order.

  1. We need to consider “+item.$level+” in the context:
return "<div class='gantt_tree_indent' onclick=collapse("+item.$level+")></div>";

Usually if there is a function we can return a variable that contains some value. Also, it can be number, string, array or object.
In this case we return the string. And “+” means that we concatenate the string. Please read this article and find concat() method:

Instead of a string we could use an array:

This article explains how to join array elements:

  1. Yes, it is possible to do that. And looks like in my previous examples I used it in a different way, not the way it was described: … ninabranch
    Here is the snippet with the example that is closer to what is written about it in the docs:

Hi Ramil,

Your suggestion really got me off the ground.
I think I can take it from here.
Many thanks and take care,