Top
You are looking at an outdated 7.1.1 version of this document. Switch to the 8.0.1 version to see the up to date information.

class anychart.data.Tree.DataItem Improve this Doc

Tree data item implementation.

Methods Overview

Miscellaneous
addChild()Adds a child.
addChildAt()Inserts a child into a specified position.
get()Gets a value from data by key.
getChildAt()Gets the child by index.
getChildren()Returns a copy of children array of current data item.
getParent()Gets a data item's parent.
indexOfChild()Gets index of child in a children array.
meta()Gets/sets a meta data.
numChildren()Returns a length of children array.
remove()Current item will be removed from parent's children and becomes an orphan.
removeChild()Removes data item's child.
removeChildAt()Removes child at specified position.
removeChildren()Removes children.
set()Sets key-value pair to the data.

Methods Description

addChild

Adds a child.

Params:

Name Type Description
child Object | anychart.data.Tree.DataItem Child to be added.

Returns:

anychart.data.Tree.DataItem - - Itself 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:

Name Type Description
child Object | anychart.data.Tree.DataItem Child to be added.
index number Position.

Returns:

anychart.data.Tree.DataItem - - Itself for method chaining.

get

Gets a value from data by key.

Params:

Name Type Description
key string Key.

Returns:

* - - Value.

getChildAt

Gets the child by index.

Params:

Name Type Description
index number Index of child to find.

Returns:

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

getChildren

Returns a copy of children array of current 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 index of child in a children array.

Params:

Name Type Description
child anychart.data.Tree.DataItem Sought child.

Returns:

number - - Index of child.

meta

Gets/sets a meta data.

Params:

Name Type Description
key string Key.
value * Value.

Returns:

* - - Value or itself for method chaining.

numChildren

Returns a length of children array.

Returns:

number - - Number of children.

remove

Current item will be removed from parent's children and becomes an orphan.

Returns:

anychart.data.Tree.DataItem - - Itself for method chaining.

removeChild

Removes data item's child.

Params:

Name Type Description
child anychart.data.Tree.DataItem Child to be removed.

Returns:

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

removeChildAt

Removes child at specified position.

Params:

Name Type Description
index number Index of item to be removed.

Returns:

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

removeChildren

Removes children.

Returns:

anychart.data.Tree.DataItem - - Itself for method chaining.

set

Sets key-value pair to the data.

Params:

Name Type Description
key string Key.
value * Value.

Returns:

anychart.data.Tree.DataItem - - Itself for method chaining.