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

class anychart.data.Iterator Improve this Doc

anychart.data.Iterator class is used to work with data in a View.
Iterator allows to get data from a anychart.data.View by crawling through rows. Iterator can be obtained using anychart.data.View#getIterator method and has methods to control current index and get values from data/metadata fields in a current row.

Methods Overview

Miscellaneous
advance()Advances the iterator to the next item.
get()Gets the value from the current row by the field name.
getIndex()Returns the index of the item to which iterator points to.
getRowsCount()Returns the number of rows in the view.
meta()Gets the metadata value by the field name.
reset()Resets the data iterator to its zero state (before the first item of the view).
select()Sets a passed index as the current index and returns it in case of success.

Methods Description

advance

Advances the iterator to the next item.

Returns:

boolean - True Returns True if moved to the next item, otherwise returns False.

get

Gets the value from the current row by the field name.
Note: Returns undefined, if no matching field found.

Params:

Name Type Description
fieldName string The name of the field to be fetched from the current row.

Returns:

* - The field value or undefined, if not found.

getIndex

Returns the index of the item to which iterator points to.

Returns:

number - The index of an iterator position.

Try it:

getRowsCount

Returns the number of rows in the view.

Returns:

number - The number of rows in the set.

meta

Gets the metadata value by the field name.
Note: Metadata is separated from user data, it exists separately, but corresponds to it.

Params:

Name Type Description
name string The name of a metadata field.

Returns:

* - Current metadata field value.

Try it:

Sets metadata value by the field name.
Note: Metadata is separated from user data, it exists separately, but corresponds to it.

Params:

Name Type Description
name string The name of a metadata field.
value * The value to be set.

Returns:

anychart.data.Iterator - anychart.data.Iterator class instance for the method chaining.

Try it:

reset

Resets the data iterator to its zero state (before the first item of the view).

Returns:

anychart.data.Iterator - anychart.data.Iterator class instance for method chaining.

select

Sets a passed index as the current index and returns it in case of success. Can be used to move the iterator point to the particular index and then fetch values.

Params:

Name Type Description
index number The index to select.

Returns:

boolean - True Returns true only when index is within a possible range, otherwise returns False.