Dynamically change open close button for a particular task

I want when the user clicks the open/close button to change the image with another one (ajax loading gif) and when the data comes from the back end to restore it back to (minus) button.

Hello Nikolai,
You can change the icon by specifying it in the styles. Here is an example:
https://snippet.dhtmlx.com/f5a7bbff0

If you parse the task that already exists in the chart (or another task with the same ID), Gantt collapses that task unless it has open: true property. If you parse other tasks, it should affect the existing ones.
So, you can save the IDs of the open tasks before parsing the data, and during the parse, open those tasks. Here is an example:
http://snippet.dhtmlx.com/374b09cb2

What i want is to change the image on the fly. When the user clicks the plus button in the tree column i want to change the image of the button with loading ajax indicator (i have set up the gantt to use branch loading) and then onloadend to restore it

Hello Nikolai,
Thank you for the clarification.
In that case, you can get the id of the opened task and when loading starts, you show the icon. The easiest way would be to modify the style property. When loading is complete, Gantt will repaint the changes and the icons will be removed. Here is an example of how it might be implemented:
http://docs.dhtmlx.com/gantt/snippet/2877d892

Thank u. This solution seems to satisfy my needs.