new Links(oChart)
The Links object holds a collection of Link objects (a link between two bars). The Chart.Links method gets access to the control's links. A link is a connection between two bars, which can be used to represent dependencies or relationships between tasks in a Gantt chart. The Links collection provides methods to add, remove, and retrieve links based on their index, identifier/key, or reference. When adding a link, the control checks if the link is allowed through the "onallowlink" event, ensuring that only valid connections are established between item-bars.
Parameters:
| Name | Type | Description |
|---|---|---|
oChart |
Chart | Specifies the control's chart as an object of Chart type. |
Members
(readonly) Count :number
The Count property gets the number of links within the collection. The Add, Remove, and Clear methods update the count automatically. The Item() method gets the link giving its index, identifier/key or reference. The Link.Visible property indicates whether the link is visible or hidden. The feL() method (short for forEachLink) invokes the callback for each link of the control. The feLU() method (short for forEachLinkUntil) invokes the callback for each link of the control, until the callback returns a not-empty value. Alternatively, you can use the Item and Count properties to enumerate all links in the collection.
Type:
- number
Example
The following statements are equivalents:
oGantt.Chart.Links.GetCount(), count of links(types of links) within the collection
oGantt.Chart.Links.Count, count of links(types of links) within the collection
where oGantt is an object of Gantt type
Count
Methods
Add(oLinkOptsopt) → {Link}
The Add() method creates and adds a link between two bars. The method accepts either a single parameter as an object of LinkOptions type that holds the options of the link to create, or multiple parameters as explained below. The method querries the control if the link is possible, through the onallowlink event. The to and from attributes of the oLinkOpts parameter must be specified; otherwise, the method returns null.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
oLinkOpts |
LinkOptions |
<optional> |
Specifies the options to create the new link as an object of LinkOptions type. |
Returns:
Returns the newly created link, as an object of Link type, or null if adding the new link fails (a link between bars is not allowed).
- Type
- Link
Example
The following statements are equivalents:
oGantt.Chart.Links.Add({from: oFrom, to: oTo}), creates and adds a link between two bars, where oFrom and oTo could be any of the following:
oGantt.Chart.Links.Create(oFrom, oTo), creates and adds a link between two bars, where oFrom and oTo could be any of the following:
where oGantt is an object of Gantt type, and oFrom and oTo could be any of the following:
oFrom/oTo {number}, indicates a numeric value that defines the index of the item (single/first item-bar of the item)
oFrom/oTo {string}, specifies a string expression that defines the identifier/key of the item (single/first item-bar of the item)
oFrom/oTo {exontrol.Gantt.ItemBar}, specifies the object reference to the item-bar
Add
Clear()
The Clear() method removes all links of the control. removed. The RemoveRange() method removes multiple-links at once. The Remove() method removes a link from the collection giving its index, identifier/key or reference. The Count property gets the number of links within the collection. The feL() method (short for forEachLink) invokes the callback for each link of the control. The feLU() method (short for forEachLinkUntil) invokes the callback for each link of the control, until the callback returns a not-empty value. Alternatively, you can use the Item and Count properties to enumerate all links in the collection.
Example
oGantt.Chart.Links.Clear(), removes all links of the control
Clear
Item(id) → {Link}
The Item() method gets the link giving its index, identifier/key or reference. The Gantt.Link(id) method is equivalent to the Item(id) method. The method returns null if the link is not found, or an object of Link type, if the links collection contains the giving id. The Add, Remove, and Clear methods update the links collection automatically. The Link.Visible property indicates whether the link is visible or hidden. The Count property gets the number of links within the collection. The feL() method (short for forEachLink) invokes the callback for each link of the control. The feLU() method (short for forEachLinkUntil) invokes the callback for each link of the control, until the callback returns a not-empty value. Alternatively, you can use the Item and Count properties to enumerate all links in the collection.
Parameters:
| Name | Type | Description |
|---|---|---|
id |
number | string | Link | The id parameter could be any of the following:
|
Returns:
Returns null if the link is not found, or an object of Link type, if the links collection contains the giving id.
- Type
- Link
Example
The following statements are equivalents:
oGantt.Chart.Links.Item(id), gets the link giving its index, identifier/key or reference, where id could be any of the following:
oGantt.Link(id), gets the link giving its index, identifier/key or reference, where id could be any of the following:
where oGantt is an object of Gantt type, and id could be any of the following:
Item
Remove(id)
The Remove() method removes a link from the collection. The method accepts either a single parameter as an index, identifier/key or reference of the link to remove. The RemoveRange() method removes multiple-links at once. The Clear() method removes all links of the control.
Parameters:
| Name | Type | Description |
|---|---|---|
id |
number | string | Link | The id parameter could be any of the following:
|
Example
The following statements are equivalents:
oGantt.Chart.Links.Remove(id), removes a link from the collection
oGantt.Link(id).Remove(), removes a link from the collection
where oGantt is an object of Gantt type
Remove
RemoveRange(range)
The RemoveRange() method removes multiple-links at once. The method accepts either a single parameter as a link, an array of Link type, or exontrol.Arr. The Clear() method removes all links of the control. The Remove() method removes a link from the collection giving its index, identifier/key or reference.
Parameters:
| Name | Type | Description |
|---|---|---|
range |
any | Indicates a link, an array of [Link] type, or exontrol.Arr. |
Example
oGantt.Chart.Links.RemoveRange([oGantt.Link(0), oGantt.Link(1)]), removes multiple-links at once
RemoveRange