Define task_text as part of raw data?


#1

This forum post shows how to use a function to define the text in the progress bar:

gantt.templates.task_text=function(start, end, task){
return ‘Some words’;
};

But how can I define this as part of my raw data. i need to calculate some content for the chart, but all the calculations have to be on the back end.

In other words, can i do soemthing like this?

{“id”:3, “text”:“task name”, “content”: “Some words”, “start_date”:“18-03-2019”, “duration”:“2”, “parent”:“1”, “progress”: 0.0, “open”: true},


#2

Hello Jeff,
You can display any task property or even HTML elements instead of the standard task text.
Here is an example:
http://snippet.dhtmlx.com/3c6566f37

If you want to modify the task text on the backend after loading the data, you need to update tasks. Here is another example:
http://snippet.dhtmlx.com/d4a1c4d09

Please, clarify if you need something else.


#3

I really need the whole thing to be read-only.
When I ran the example code, it changed both the sidebar and the contents of the task. I want the sidebar to not change.

What I want is to have the task name on the left be different from the text in the schedule bar. The schedule component is going to contain some meta-data about the task.


#4

Hello Jeff,
Thank you for the clarification.
Have you tried the first snippet? (http://snippet.dhtmlx.com/3c6566f37)
The task_text template doesn’t change the data, it only modifies what is displayed in the taskbar:
https://docs.dhtmlx.com/gantt/api__gantt_task_text_template.html