new ItemBars(oItem)
The ItemBars object holds a collection of ItemBar objects. The Item.Bars property returns the collection of bars in the item, as an object of ItemBars type. The ItemBar objects define the look and feel for bars in the item. The ItemBar method of the control, returns the item-bar based on the item and its key, as an object of Gantt.ItemBar type (equivalent of Item.ItemBar method). The Add, Remove and Clear methods of the ItemBars collection add, remove and clear item-bars from the collection, respectively.
The following methods are equivalent:
- ItemBars.Add method with AddBar method, for adding bars for the item
- ItemBars.Remove method with RemoveBar method, for removing bars of the item
- ItemBars.Clear method with ClearBars method, for clearing bars of the item
- ItemBars.Item method with ItemBar method, for getting a specific bar of the item giving its key
Parameters:
| Name | Type | Description |
|---|---|---|
oItem |
Item | Specifies the item that holds the bar, as an object of Item type. |
Example
oItem.Bars, gets the collection of bars in the item, as an object of ItemBars type
Methods
Add(name, start, end, key, text) → {ItemBar}
The Add() method adds a bar for current item, and returns an object of ItemBar type. The method accepts either a single parameter as an object of ItemBarOptions type that holds the options of the bar to create, or multiple parameters as explained below. If a bar with the same key already exists, the existing bar's options are updated with the provided options instead of creating a new bar. The Add method is equivalent to the AddBar method.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Indicates the name of the bar to create or an object of ItemBarOptions type that specifies the options of the bar to create (single parameter). |
start |
Date | Specifies the date-time the bar starts from. |
end |
Date | Specifies the date-time the bar ends to. |
key |
any | Indicates the key of the bar to create. |
text |
string | Specifies the bar's exHTML caption. |
Returns:
Returns undefined (adding the item-bar failed) or an object of ItemBar type that holds the bar being created
- Type
- ItemBar
Example
The following statements are equivalents:
oItem.Bars.Add(name, start, end, key, text), adds a bar for current item, and returns an object of ItemBar type
oItem.Bars.Add({name: name, start: start, end: end, key: key, caption: text}), adds a bar for current item, and returns an object of ItemBar type
oItem.AddBar(name, start, end, key, text), adds a bar for current item, and returns an object of ItemBar type
oItem.AddBar({name: name, start: start, end: end, key: key, caption: text}), adds a bar for current item, and returns an object of ItemBar type
where oItem is an object of Item type
Add
Clear()
The Clear() method removes all bars of the control. The Remove method removes a bar from the collection giving its key. The RemoveRange method removes multiple-bars at once, and accepts either a single parameter as a bar, an array of ItemBar type, or exontrol.Arr, or multiple parameters. The Clear method is equivalent to the ClearBars method.
Example
The following statements are equivalents:
oItem.Bars.Clear(), removes all bars of the control
oItem.ClearBars(), removes all bars of the control
oItem.Bars = null, removes all bars of the control
oItem.SetBars(null), removes all bars of the control
where oItem is an object of Item type
Clear
Item(key) → {object}
The Item() method gets a bar by its index, key, or reference. The Item method is equivalent to the Item.ItemBar method. The Remove method removes a bar from the collection by its key. The Clear method removes all bars from the control. The control's Gantt.ItemBar method directly returns the item-bar based on the item and its key, as an object of type ItemBar (equivalent to the Item.ItemBar method).
Parameters:
| Name | Type | Description |
|---|---|---|
key |
any | The key parameter could be any of the following:
|
Returns:
Returns null(the bar is not found), or an object of ItemBar type, if the bars collection contains the giving key.
- Type
- object
Example
The following statements are equivalents:
oItem.Bars.Item(key), gets the bar giving its index, key or reference, as an object of ItemBar type
oItem.ItemBar(key), gets the bar giving its index, key or reference, as an object of ItemBar type
where oItem is an object of Item type
Item
Remove(key)
The Remove() method removes a bar from the collection. The method accepts either a single parameter as the key of the bar to remove, or multiple parameters as explained below. The Remove method is equivalent to the RemoveBar method. The RemoveRange method removes multiple bars at once, and accepts either a single parameter as a bar, an array of ItemBar type, or exontrol.Arr, or multiple parameters. The Clear method removes all bars of the control. The ItemBar.Remove removes the bar itself.
Parameters:
| Name | Type | Description |
|---|---|---|
key |
any | The key parameter could be any of the following:
|
Example
The following statements are equivalents:
oItem.Bars.Remove(key), removes a bar from the collection giving its key, and the key parameter could be any of the following:
oItem.RemoveBar(key), removes a bar from the collection giving its key, and the key parameter could be any of the following:
where oItem is an object of Item type, and the key indicates the bar to remove
Remove
RemoveRange(range)
The RemoveRange() method removes multiple-bars at once. The method accepts either a single parameter as a bar, an array of ItemBar type, or exontrol.Arr, or multiple parameters as explained below. The Remove method removes a bar from the collection giving its key. The Clear method removes all bars of the control.
Parameters:
| Name | Type | Description |
|---|---|---|
range |
any | Indicates a bar, an array of [Bar] type, or exontrol.Arr. |
Example
The following statements are equivalents:
oGantt.Item(0).Bars.RemoveRange(oGantt.Item(0).Bars.Items("0,1")), removes multiple-bars at once, giving a list of index/key separated by comma character
oGantt.Item(0).Bars.RemoveRange([oGantt.Item(0).Bars.Item(0), oGantt.Item(0).Bars.Item(1)]), removes multiple-bars at once, giving an array of bars to remove
where oGantt is an object of Chart type
RemoveRange