new Item()
The Item type defines additional properties and methods of the Item(extree) type. The Item(id) method returns the item based on its index or identifier.
Methods
(static) AddBar(name, start, end, keyopt, textopt) → {ItemBar}
The AddBar() method adds a bar for the current item, and returns an object of ItemBar type
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
string | Indicates the name/type 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 |
<optional> |
Indicates the key of the bar to create |
text |
string |
<optional> |
Specifies the bar's exHTML caption |
Returns:
Returns the newly created item-bar, as an object of ItemBar type (no item-bar is created if the item already hosts an item-bar with the same key)
- Type
- ItemBar
Example
The following sample adds a new "Task" bar for each item being added:
oGantt.Listeners.Add("onadditem", function(oItem)
{
oItem.AddBar("Task", "#" + oItem.Cell("Start").Value + "#", "#" + oItem.Cell("End").Value + "#");
});
or
oGantt.on("additem", function(oItem)
{
oItem.AddBar("Task", "#" + oItem.Cell("Start").Value + "#", "#" + oItem.Cell("End").Value + "#");
});
AddBar
(static) ClearBars()
The ClearBars() method clears all bars of the item
(static) GetBars() → {ItemBars}
The GetBars() method gets the bars of the current item
- Since:
- 1.7
Returns:
Returns null or undefined (no bar) or an object of {ItemBars} type that holds the bars of the item
- Type
- ItemBars
(static) GetNonworkingUnits() → {string}
The GetNonworkingUnits() method gets a formula that determines the use of custom non-working units for the item. The NonworkingDays and NonworkingHours properties define the non-working periods for the chart, applied to items where nonworkingUnits is undefined.
- Since:
- 4.3
Returns:
Returns a formula for using custom non-working units for the item. The expression supports predefined constants, operators and "value" keyword. The value keyword indicates the date-time unit to check, as a Date type.
- Type
- string
Example
"0" {string}, all only working units, no not-working units
"month(value) = 1" {string}, all January is non-working
"weekday(value) = 0" {string}, all Sundays are non-working only
GetNonworkingUnits
(static) ItemBar(key) → {ItemBar}
The ItemBar() method gets the bar of the current item giving its key, and returns an object of ItemBar type
Parameters:
Name | Type | Description |
---|---|---|
key |
any | Specifies the key of the bar to request |
Returns:
Returns undefined (no bar found) or an object of ItemBar type that holds the bar being created
- Type
- ItemBar
(static) RemoveBar(key) → {object}
The RemoveBar() method removes a bar of the current item giving its key
Parameters:
Name | Type | Description |
---|---|---|
key |
any | Specifies the key of the bar to delete |
Returns:
Returns undefined (no bar found) or an object of ItemBar type that holds the bar being created
- Type
- object
(static) SetBars() → {ItemBars}
The GetBars() method gets the bars of the current item
- Since:
- 1.7
Returns:
Returns null or undefined (no bar) or an object of ItemBars type that holds the bars of the item
- Type
- ItemBars
(static) SetNonworkingUnits(value)
The SetNonworkingUnits() method sets a formula that determines the use of custom non-working units for the item. The NonworkingDays and NonworkingHours properties define the non-working periods for the chart, applied to items where nonworkingUnits is undefined.
Parameters:
Name | Type | Description |
---|---|---|
value |
string | Indicates the formula for using custom non-working units for the item. The expression supports predefined constants, operators and "value" keyword. The value keyword indicates the date-time unit to check, as a Date type. |
- Since:
- 4.3
Example
"0" {string}, all only working units, no not-working units
"month(value) = 1" {string}, all January is non-working
"weekday(value) = 0" {string}, all Sundays are non-working only
SetNonworkingUnits