getColumnIndex

returns the index of the column by its name

number getColumnIndex(string | number name, [boolean excludeHidden] );
namestring | numberthe name of the column
excludeHiddenbooleanskips indexes of the hidden columns
numberthe index of the column

Example

var index = gantt.getColumnIndex("start_date"); // => 1

Details

If the excludeHidden parameter is set to true, the method won't count the columns which are hidden via the hide:true option of the config:

gantt.config.columns = [
    {name: "text", label: "Task name", width: "*", tree: true, resize: true },
    {name: "start_date", label: "Start time" },
    {name: "duration", label: "Duration", width: 60, hide:true  },     {name: "planned_start", label: "Planned start", hide:true  },      {name: "planned_end", label: "Planned end", width:80, hide:true  },     {name: "add", label: "", width: 36 }
];
 
gantt.init("gantt_here");
 
gantt.getColumnIndex("add"); // => 5 gantt.getColumnIndex("add", true); // => 2
Back to top