Class: DataSourceCollection

DataSourceCollection

new DataSourceCollection()

DataSource实例集合。

Members

readonly dataSourceAddedEvent

将数据源添加到集合时触发的事件。由事件处理程序传递添加的数据源。

readonly dataSourceMovedEvent

数据源改变在集合的索引位置触发的事件。并且传递移动的数据源对象,以及它的新索引,旧索引给事件处理器。

readonly dataSourceRemovedEvent

移除集合中的数据源时触发的事件。由事件处理程序传递被移除的数据源。

readonly lengthNumber

获取集合中数据源的数量。

Methods

add(dataSource){Promise.<DataSource>}

集合中添加数据源。

Name Type Description
dataSource DataSource | Promise.<DataSource>

待添加的数据源或数据源的promise。传递promise解析成功后数据源添加到集合中。

Returns:
Type Description
Promise.<DataSource> 数据源添加到集合中所解析的promise。

contains(dataSource){Boolean}

检测集合中是否包含指定的数据源。

Name Type Description
dataSource DataSource

待检索的数据源。

Returns:
Type Description
Boolean true 集合中包含返回true,否则返回false。

destroy()

释放集合中所有数据源所占用的资源。一旦释放对象资源,它将不能被使用;调用任何方法将会抛出DeveloperError异常。

See:
Throws:

对象已经被销毁。

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

get(index){DataSource}

获取集合中指定索引的数据源。

Name Type Description
index Number

指定的索引号。

Returns:
Type Description
DataSource 数据源。

getByName(name){Array.<DataSource>}

从集合中通过数据源名称获取数据源对象。

Name Type Description
name String

数据源名称。

Returns:
Type Description
Array.<DataSource> 一个名称匹配输入名称的数据源数组。

indexOf(dataSource){Number}

确定指定数据源在集合中的索引号。

Name Type Description
dataSource DataSource

待检索的数据源。

Returns:
Type Description
Number 数据源在集合中的索引号,如果集合不包含该数据源,返回-1。

isDestroyed(){Boolean}

如果对象被销毁返回true,否则返回false。一旦释放对象资源,它将不能被使用;调用任何方法将会抛出DeveloperError异常。

See:
Returns:
Type Description
Boolean

lower(dataSource)

在集合中把数据源降低一个位置。

Name Type Description
dataSource DataSource

要移动的数据源对象。

Throws:
  • dataSource is not in this collection.

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

    Type
    DeveloperError

lowerToBottom(dataSource)

把数据源对象移到集合的底部。

Name Type Description
dataSource DataSource

要移动的数据源对象。

Throws:
  • dataSource is not in this collection.

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

    Type
    DeveloperError

raise(dataSource)

在集合中把数据源提升一个位置。

Name Type Description
dataSource DataSource

要移动的数据源对象。

Throws:
  • dataSource is not in this collection.

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

    Type
    DeveloperError

raiseToTop(dataSource)

把数据源对象移到集合的顶部。

Name Type Description
dataSource DataSource

要移动的数据源对象。

Throws:
  • dataSource is not in this collection.

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

    Type
    DeveloperError

remove(dataSource, destroy){Boolean}

移除集合中的一个数据源。

Name Type Default Description
dataSource DataSource

待移除的数据源。

destroy Boolean false 可选

指定是否在移除后销毁数据源。

Returns:
Type Description
Boolean 集合中存在的数据源移除后,返回true;如果集合中不存在该数据源,移除失败,返回false。

removeAll(destroy)

移除集合中的所有数据源。

Name Type Default Description
destroy Boolean false 可选

指定是否在移除后销毁数据源。