So you want to render some more data on the Gantt?
For example:
Consider you have a Work item of type Epic and you want to render Owner field to the right of the task
To do so, you need to things:
- Prepare the data
- Configure how to render the data
Prepare the data
To prepare the data you use the Advanced > Item Script parameter, and put the following snippet there:
if(wi.getType().getId()==='epic'){ var o = wi.getValue("owner"); if(o!=null){ task.getFields().put("owner",o.getName()); } }
You see, it is simple, you can keep passing any additional data using task.getFields().put(KEY,VALUE)
Configure how to render the data
Now, let's set the template to render the right side text via, you can do it via Advanced > Gantt Config Script widget parameter. Put the following snippet there:
gantt.templates.rightside_text = function(start, end, task){ return (task.fields.owner?"Owner: <b>"+task.fields.owner+"</b>":""); };
That's it. Now the Gantt will render an Owner to the right to the task.
What else you can render? If you want to render the "assignee" field, use the following Item Script
if(wi.getType().getId()==='portfolioepic'){ var aIt = wi.getAssignees().iterator(); var assignees = ""; var separator = ""; while(aIt.hasNext()){ var assignee = aIt.next(); assignees = assignees + separator + assignee.name; separator = ","; } if(assignees!=""){ task.getFields().put("assignees",assignees); } }
Show only icon of status
To display only the icon of the status, use following script in the 'Gantt Config Script':
gantt.templates.rightside_text = function(start, end, task){ return "<b><img src='" + task.fields.statusIcon + "'/> </b> " };
As a result, status name will no longer be shown:
For guidance to adjust the right-text properties, check our article: Adjust the right-side text properties
If you need assistance or have further questions, feel free to contact us at [email protected]
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article