RadiantQ jQuery Gantt Package
Overriding Dependency Setup Behavior
Previous Topic  Next Topic 

By default when the user connects 2 tasks a "Finish to Start" dependency will be setup. You can override this behavior to change the dependency type or simply cancel/prevent dependency between specific tasks by providing a NewDependencyValidator method as follows:


var $gantt_container = $('#gantt_container');

$gantt_container.GanttControl({

     DataSource: self.jsonData,

});


var GanttControl = $gantt_container.data("GanttControl");

GanttControl.Model.NewDependencyValidator = NewDependencyValidator;


Then implement the above method as follows:


function NewDependencyValidator(/*IActivity*/ from, /*IActivity*/ to, /*NewDependencyAddScenarioType*/ addType) {

    // Setup a workaround to change default dependency types to FF rather than FS.

    if (addType == RadiantQ.Gantt.Model.NewDependencyAddScenarioType.UserDragDrop) {

        // If the user has connected 2 tasks in the Chart to setup dependency, first cancel that op, by returning false below....

        setTimeout(function () {

            // .... and instead create a new FF dependency here.

            GanttControl.Model.CreateNewDependency(from, to, RadiantQ.Gantt.DependencyType.FinishToFinish, RQTimeSpan.Zero);

        }, 0);


        return false;

    }

    else {

        // All other scenarios, simply return true to allow normal processing.

        return true;

    }

}


© RadiantQ 2022. All Rights Reserved.