Class: DataSourceCollection

DataSourceCollection

new DataSourceCollection()

Dataset instance collection.

Members

readonly dataSourceAddedEvent

The event triggered when adding a data source to a collection. Pass the added data source through the event handler.

readonly dataSourceMovedEvent

The event triggered by a data source change at the index position of a collection. And pass the moving data source object, as well as its new index and old index, to the event handler.

readonly dataSourceRemovedEvent

The event triggered when removing a data source from a collection. Pass the removed data source through the event handler.

readonly lengthNumber

Get the number of data sources in the collection.

Methods

add(dataSource){Promise.<DataSource>}

Add data sources to the collection.

Name Type Description
dataSource DataSource | Promise.<DataSource>

Promise of the data source or data source to be added. After the promise is successfully resolved, the data source is added to the collection.

Returns:
Type Description
Promise.<DataSource> The promise parsed by adding the data source to the collection.

contains(dataSource){Boolean}

Check if the collection contains the specified data source.

Name Type Description
dataSource DataSource

The data source to be retrieved.

Returns:
Type Description
Boolean The 'true' collection contains a return of 'true', otherwise it returns' false '.

destroy()

Release the resources occupied by all data sources in the collection. Once the object resource is released, it cannot be used; Calling any method will throw a Developers Error exception.

See:
Throws:

The object has been destroyed.

Type
DeveloperError
Example
dataSourceCollection = dataSourceCollection && dataSourceCollection.destroy();

get(index){DataSource}

Retrieve the data source of the specified index in the collection.

Name Type Description
index Number

The specified index number.

Returns:
Type Description
DataSource Data source.

getByName(name){Array.<DataSource>}

Retrieve the data source object from the collection by its name.

Name Type Description
name String

Data source name.

Returns:
Type Description
Array.<DataSource> A data source array with a name that matches the input name.

indexOf(dataSource){Number}

Determine the index number of the specified data source in the collection.

Name Type Description
dataSource DataSource

The data source to be retrieved.

Returns:
Type Description
Number The index number of the data source in the collection. If the collection does not contain the data source, return -1.

isDestroyed(){Boolean}

If the object is destroyed, return true; otherwise, return false. Once the object resource is released, it cannot be used; Calling any method will throw a Developers Error exception.

See:
Returns:
Type Description
Boolean

lower(dataSource)

Lower the data source by one position in the collection.

Name Type Description
dataSource DataSource

The data source object to be moved.

Throws:
  • dataSource is not in this collection.

    Type
    DeveloperError
  • This object was destroyed, i.e., destroy() was called.

    Type
    DeveloperError

lowerToBottom(dataSource)

Move the data source object to the bottom of the collection.

Name Type Description
dataSource DataSource

The data source object to be moved.

Throws:
  • dataSource is not in this collection.

    Type
    DeveloperError
  • This object was destroyed, i.e., destroy() was called.

    Type
    DeveloperError

raise(dataSource)

Elevate the data source by one position in the collection.

Name Type Description
dataSource DataSource

The data source object to be moved.

Throws:
  • dataSource is not in this collection.

    Type
    DeveloperError
  • This object was destroyed, i.e., destroy() was called.

    Type
    DeveloperError

raiseToTop(dataSource)

Move the data source object to the top of the collection.

Name Type Description
dataSource DataSource

The data source object to be moved.

Throws:
  • dataSource is not in this collection.

    Type
    DeveloperError
  • This object was destroyed, i.e., destroy() was called.

    Type
    DeveloperError

remove(dataSource, destroy){Boolean}

Remove a data source from the collection.

Name Type Default Description
dataSource DataSource

Data sources to be removed.

destroy Boolean false optional

Specify whether to destroy the data source after removal.

Returns:
Type Description
Boolean After removing the existing data sources in the collection, return true; If the data source does not exist in the collection, removal fails and returns false.

removeAll(destroy)

Remove all data sources from the collection.

Name Type Default Description
destroy Boolean false optional

Specify whether to destroy the data source after removal.