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:

  1. Prepare the data
  2. Configure how to render the data


Prepare the data

To prepare the data you use the Advanced > Item Script parameter, put following snippet there:


if(wi.type.id==='epic'){
    var o = wi.getValue("owner");
    if(o!=null){
        task.getFields().put("owner",o.getName());
    }
}


You see, it is simple, you can keep pass any additional data using task.getFields().put(KEY,VALUE)


Configure how to render the data

Now lets set the template to render the right side text via, you can do it via Advanced > Gantt Config Script widget parameter. Put following snippet there:


gantt.templates.rightside_text = function(start, end, task){
    return  (task.fields.owner?"Owner: <b>"+task.fields.owner+"</b>":"");
};


That's it. Not 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 following Item Script


if(wi.type.id==='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);
    } 
}