How to set a custom value for Configuration Column

I am using the Gantt chart with Angular 7. I want a custom value in one of my configuration columns, but I can’t access external variables other than the obj var. I tried following the example here https://docs.dhtmlx.com/gantt/api__gantt_columns_config.html

However, I want to be able to retrieve other variables other than obj, but the scope of the function does not let me access other variables such as myVar which is defined globally.

gantt.config.columns =  [
    {name:"text",       label:"Task name",  tree:true, width:'*' },
    {name:"start_date", label:"Start time", align: "center" },
    {name:"staff",      label:"Holder(s)", template: function(obj){
                                return obj.holder+myVar} }
];

I also tried creating a new function that I can call in the template.

myFunction(obj) {
   return obj.text + myVar;
}

gantt.config.columns =  [
    {name:"text",       label:"Task name",  tree:true, width:'*' },
    {name:"start_date", label:"Start time", align: "center" },
    {name:"staff",      label:"Holder(s)", template: myFunction(obj) }
];

But in the above example, obj cannot be found.

Any ideas? Thank you!

Hello Chris,
You can return the task ID, obtain the task object in the custom template function and return the property you need.
Here is a demo:
https://files.dhtmlx.com/30d/dc595c4f8ee4153e189497ea8df9ee87/angular7+grid-custom-template.zip

1 Like

ramil than you! This implementation worked for me :wink: