AnyChart
API Reference
Still have questions?
Contact support
Top

class anychart.data.Tree.DataItem Improve this Doc

Tree data item.

Methods Overview

Data
addChild()Adds a child.
addChildAt()Inserts a child into a specified position.
del()Removes from data by specified path.
get()Gets a value from data by key.
getChildAt()Gets the child by index.
getChildren()Returns a copy of children array of the data item.
getParent()Gets a data item's parent.
indexOfChild()Gets the index of child in a children array.
meta()Metadata settings.
numChildren()Returns a length of children array.
remove()Removes data item.
removeChild()Removes data item's child.
removeChildAt()Removes child at specified position.
removeChildren()Removes children.
set()Sets a value to the data by path.

Methods Description

addChild

Adds a child.

Params:

NameTypeDescription
childObject | anychart.data.Tree.DataItemChild for add.

Returns:

anychart.data.Tree.DataItem - Self instance for method chaining.

addChildAt

Inserts a child into a specified position.
Please make sure that child has not inner cycles to avoid stack overflow exception.

Params:

NameTypeDescription
childObject | anychart.data.Tree.DataItem | anychart.data.TreeView.DataItemChild for add.
indexnumberPosition for add child.

Returns:

anychart.data.Tree.DataItem - Self instance for method chaining.

del

Removes from data by specified path.

Params:

NameTypeDescription
var_args*Path to set.

Returns:

anychart.data.Tree.DataItem - Self instance for method chaining.

get

Gets a value from data by key.

Params:

NameTypeDescription
keystringKey.

Returns:

* - Value.

getChildAt

Gets the child by index.

Params:

NameTypeDescription
indexnumberIndex of child to find.

Returns:

anychart.data.Tree.DataItem | undefined - Child into a specified position.

getChildren

Returns a copy of children array of the data item.

Returns:

Array.<anychart.data.Tree.DataItem> - Copy of children array.

getParent

Gets a data item's parent.

Returns:

anychart.data.Tree.DataItem - Parent.

indexOfChild

Gets the index of child in a children array.

Params:

NameTypeDescription
childanychart.data.Tree.DataItem | anychart.data.TreeView.DataItemChild for getting of index.

Returns:

number - Index of child.

meta

Getter for a meta data.

Params:

NameTypeDescription
keystringKey.

Returns:

* - Value.
Setter for a meta data.

Params:

NameTypeDescription
keystringKey.
value*Value to set.

Returns:

* - Value.

numChildren

Returns a length of children array.

Returns:

number - Number of children.

remove

Removes data item.

Returns:

anychart.data.Tree.DataItem - Self instance for method chaining.

removeChild

Removes data item's child.

Params:

NameTypeDescription
childanychart.data.Tree.DataItemChild for removal.

Returns:

anychart.data.Tree.DataItem - Removed element or null.

removeChildAt

Removes child at specified position.

Params:

NameTypeDescription
indexnumberIndex of item for removal.

Returns:

anychart.data.Tree.DataItem - Removed item or null if item is not found.

removeChildren

Removes children.

Returns:

anychart.data.Tree.DataItem - Self instance for method chaining.

set

Sets a value to the data by path.

Params:

NameTypeDescription
var_args*Path to set.

Returns:

anychart.data.Tree.DataItem - Self instance for method chaining.