Gantt Relationships

Hi,

Some questions on the default behavior of gantt relationships.

The default relationship created on dragging a link from a Task End point to the midpoint of another task is “Finish to Finish”, can this be configured to be “Finish to Start” by default ?

Also using the gantt relationships, it is possible for a user to create a circular relationship, is there any configuration in the API to avoid this ?

Thanks
Kevin

Hello,

Right now there is no configuration for this. Well add setting to the dev version in the very nearest time, please stay in touch.

Currently links(relationships) do not have built-in way to affect the gantt. I.e. at the moment, relationships are just links between two tasks, no further logic involved. Examples of constraints that you can find in our examples are implemented via public API of the component.
We plan to develop functionality for links, but most probably it won’t be included into upcoming update, and will be introduced in summer.

In order to forbid creating circular links, you can catch onBeforeLinkAdd event and check if the new link creates circle with already existing relations (you’ll have to manually bypass the tree of links and find such circles). I could send an example if you need it
docs.dhtmlx.com/gantt/api__gantt … event.html

Hi Aliaksandr,

Yes, if you have some code on how to detect a circular reference, it would be appreciated.

Thanks
Kevin

Hello Kevin,
If i’m not mistaken, code should look like following:

[code]function findLinkBetween(targetTask, sourceTask){
var task = gantt.getTask(targetTask)
for(var i=0; i < task.$source.length; i++){
var link = gantt.getLink(task.$source[i]);

	if(link.target == sourceTask){
		return true;
	}
	//recursively inspect chain of linked tasks
	if(findLinkBetween(link.target, sourceTask)){
		return true;
	}

}
return false;

}

gantt.attachEvent(“onBeforeLinkAdd”, function(id,item){
if(findLinkBetween(item.target, item.source)){
dhtmlx.message(“Can’t create circular link!”);
return false;
}else{
dhtmlx.message(“All seems correct”);
return true;
}
});[/code]

Hi Aliaksandr,

Thanks, exactly what I was looking for.

Kevin