Not able to address the following usecase. I have a few fields which are user created which I would like to display to user.
I tried following code to add column to Gantt grid however, it doesn’t work since template function doesn’t have any information of column and just gives ganttTask model in argument. Here is the code I tried:
if(this.ganttTasks[0].task.CustomFields.length > 0){
var customFieldColumns = [];
for(var i =0; i < this.ganttTasks[0].task.CustomFields.length; i++){
var name = this.ganttTasks[0].task.CustomField[i].Name;
var customFieldId = this.ganttTasks[0].task.CustomFields[i].CustomFieldId;
var add_column = {
name: "custom_field_"+ customFieldId, label: name, align: "center", resize: true, hide: true,
template: (ganttTask: GanttTaskModel) =>{
var value = "";
var cft = ganttTask.task.CustomFields.find(x=> x.CustomFieldId == customFieldId);
switch (cft.Type) {
case CustomFieldTypeEnum.Text:
value = cft.TextValue;
break;
case CustomFieldTypeEnum.Number:
value = cft.NumberValue.toString();
break;
case CustomFieldTypeEnum.Enum:
value = cft.EnumValue.EnumId == undefined ? null : cft.EnumValue.Name;
break;
}
return value;
}
}
customFieldColumns.push(add_column);
}
this.ganttColumns.push.apply(this.ganttColumns,customFieldColumns);
}
Specifically in the above code, the customFieldId
is not available inside the template. If I have the information of the column too inside the template I could solve this issue.
Looking forward to a solution to this.