isLinkAllowed

checks whether the specified link is correct

boolean isLinkAllowed(object link);

Parameters

linkobjectthe link object

Returns

booleantrue, if the link is correct. Otherwise, false

Example

var link = {
    source:2,
    target:2,
    type:gantt.config.link.start_to_start
};
if(gantt.isLinkAllowed(link))// -> false (because source==target)
    gantt.addLink(link);

Details

The cases when a link is considered as incorrect:

  1. The source task's id is equal to the target task's id.
  2. If the type is set to a value that is not 0, 1 or 2.
  3. If the link failed the validation.

The method invokes the onLinkValidation event


Note, there is the 2nd way to call the method:

gantt.isLinkAllowed(from, from_start, to, to_start )

where

  • from - (string, number) the id of the source task
  • from_start - (boolean) true, if the link is being dragged from the start of the source task, false - if
    from the end of the task
  • to - (string, number) the id of the target task( 'null' or 'undefined', if the target task isn't specified yet)
  • to_start - (boolean) true, if the link is being dragged to the start of the target task, false - if
    to the end of the task

For example, the code above you alter as in:

//var link = {
//    source:2,
//    target:2,
//    type:gantt.config.link.start_to_start
//};
 
if(gantt.isLinkAllowed(2, true, 2, true))// -> false (because source==target)
    //do something
Back to top