Task Color Not Changing

I’m trying to get the background color of tasks to change using the method of specifying style in the properties of the task object.

I specifically want the tasks to be different colors when the parent they are under is collapsed and the tasks are displaying in the same row.

For example:
var tasks = {
data: [
{ id: 1, text: “Project #1”, start_date: “01-05-2016”, duration: 1, color: “red” },
{ id: 2, text: “Task #1”, start_date: “02-05-2016”, duration: 1, color: “blue”, parent: 1 }]};

When the parent is collapsed, there should be 2 tasks next to each other on the same row, 1 red and 1 blue.

This isn’t changing the background color though, the tasks color just stays the default color that is specified in the css.
What am I doing wrong here?

Also I can’t use the method of setting the color by redefining the task’s template, as I have subtasks I want to change the color of and this only seems to work on parents/projects.

Any advice on this would be appreciated.

Hello,

You need to use gantt.refreshTask or gantt.render method after changing value of task.color.
See example:
docs.dhtmlx.com/gantt/snippet/3ba3b8ea

docs.dhtmlx.com/gantt/api__gantt_render.html
docs.dhtmlx.com/gantt/api__gantt … htask.html

Hi Polina, I used your snippet, and the code works perfectly. But the color does that save, so when I return to the chart the values are back to normal. Is this something that you can help implement?