Defining templates and exporting/printing with Gantt Chart Hyper Library

If you set up grid column and task bar template functions when using Gantt Chart Hyper Library, and would like to export or print content from the component, you should write your custom code with extra care:

Specifically, you'd need to ensure the document object refers to the current one of the item, and if you plan to access custom fields of the item object, you should redirect item variable to its tag field when isExported value returns true:

column.cellTemplate = function (item) {
    var document = item.ganttChartView.ownerDocument;
    var originalItem = !item.isExported ? item : item.tag;
    // Safely access document and originalItem.customField objects as needed
    [...]
}

Moreover, for custom task bar template functions that inherit from original templates and require exporting or printing, you should ensure that you call getDefault* static methods without parameters to infer them at runtime, and optionally, if you need to access them, preset ganttChartView and settings objects dynamically, using the appropriate fields of the item object:

var originalStandardTaskTemplate = DlhSoft.Controls.GanttChartView.getDefaultStandardTaskTemplate(); settings.standardTaskTemplate = function (item) {
    var ganttChartView = item.ganttChartView;
    var settings = ganttChartView.settings;
    var document = ganttChartView.ownerDocument;
    var svgGroup = originalStandardTaskTemplate(item);
    var originalItem = !item.isExported ? item : item.tag;
    // Safely access document and originalItem.customField objects as needed
    [...]
}