Skip to content

Interface

The interface for all data sources.

Conceptually, we have four types of data sources but all of them are created as data source object:

  • Main data source: the data source user added in data panel.
  • Data view: the data view user created in data panel.
  • Local data source: when multiple widgets connect to a main data source or a data view, they'll share the same data records. If you need to use a local data copy, you can create a local data source from a main data source by using DataSourceManager.getInstance().createLocalDataSource() .
  • Local data view: a local data source created from a data view.

Data view, local data source or local data view derived from the same main data source will share the same schema, same selection records, but may have different data records. The schema is in main data source only.

To share the selection between data source and view, we create a selection data view when creating the data source. The selection data source view ID is: ${dataSourceId}-selection . When selecting records, the selected records are copied to the selection data view.

Properties

PropertyTypeNotes
belongToDataSourceDataSource

The data source which this data source derives from.

countnumber

The total records count depends on the current query

dataSourceManagerDataSourceManager

The data source manager, which is used to manage the data source, including create/get/destroy the data source instance.

dataViewIdstring

The data view ID configured in JSON.

idstring

The data source ID.

isDataViewboolean

True means the data source is a data view. For local data source, this is false even the local data source is created from a data view.

isLocalboolean

True means the data source is a local data source.

localIdstring

The local ID of the data source.

ordernumber

Order in the parent data source.

parentDataSourceDataSource & SetDataSourceMixin

The parent data source of this data source, mull means it's a root data source.

typestring

The type of the data source.

belongToDataSource

optional
Interface Property

count

optional
Interface Property

dataSourceManager

Interface Property

dataViewId

optional
Interface Property

id

Interface Property

isDataView

Interface Property

isLocal

Interface Property

localId

optional
Interface Property

order

optional
Interface Property

parentDataSource

Interface Property

type

Interface Property

Methods

MethodReturnsNotes
addSourceVersion()void

When current data source is created from an array of records, it will be saved in sourceRecords . Add the version of sourceRecords . setSourceRecords will add the version by default.

addVersion()void

Update data source version.

buildRecord(data)DataRecord

Builds a data record only -- does not add the record into data source.

clearRecords()void

This function will clear the loaded records and won't clear the sourceRecords. Once the loaded records are cleared, the version in the data source info will be updated.

clearSourceRecords()void

Clear both sourceRecords and loaded records. Both source version and version in data source info will be updated.

destroy()void

Destroy the data source.

fetchSchema()Promise<IMDataSourceSchema>

Fetch the data schema from an actual data source. If it's a statistic data source, the schema will not be fetched.

getAllDerivedDataSources()DataSource[]

Return the derived data views and local data sources.

getCountStatus()DataSourceStatus

Return data source count status.

getDataSourceJson()IMDataSourceJson

The data source JSON object in app config.

getDataView(dataViewId)DataSource

Get data view by data view ID.

getDataViewConfig()IMDataViewJson

Return the config of the current data source.

getDataViews()DataSource[]

Return all data views created from a main data source.

getIdField()string

Return the data source ID field.

getInfo()IMDataSourceInfo

Return the data source info in redux store.

getLabel()string

Return data source label.

getListenSelection()boolean

Return whether listen selection.

getLocalDataSource(localId)DataSource

Get local data source by local ID.

getLocalDataSources()DataSource[]

Return all local data sources created from a main data source or data view.

getMainDataSource()DataSource

Return the main data source.

getRecordById(id)DataRecord

Get record by ID

getRecords()DataRecord[]

Get records

getRecordsWithSelection()DataRecord[]

If selected records are not loaded in the current data source, they will be concatenated to the end of records array. For example, record 1 is selected in data view 1 and it is not loaded in data view 2 (record 1 actually matches query params of data view 2), dataView2.getRecordsWithSelection() will return all loaded records in data view 2 and record 1.

getRootDataSource()DataSource

Return the root data source.

getSchema()IMDataSourceSchema

The schema returned here is the merged result of the configured schema and the fetched schema. The configured schema is the user's changes, such as a new data source name. The fetched schema is the original schema from AGOL/portal item or a remote database, such as the service name, the fields and the filters.

getSelectedRecordIds()string[]

Get selected record IDs

getSelectedRecordIndexes()number[]

Get selected record indexes

getSelectedRecords()DataRecord[]

Get selected records

getSelectionDataView()DataSource

Get selection data view

getSourceRecords()DataRecord[]

Return the source records

getSourceVersion()number

When current data source is created from an array of records, it will be saved in sourceRecords . Return the version of sourceRecords .

getStatus()DataSourceStatus

Return data source status.

getVersion()number

Return data source version.

isDataSourceSet()thisisDataSource & SetDataSourceMixin

Whether a data source contains child data sources. A set data source won't create all its child data sources when ready is resolved. To make sure all child data sources are created, please use childDataSourcesReady .

isInAppConfig()boolean

Return whether the data source is added in builder and is saved in app config.

isSelectionView()boolean

Determine whether the data source is a selection view.

ready()Promise<any>

Ready is resolved means the data source instance is ready for use. Please note that can not make sure all child data sources are created if a set data source is ready. To make sure all child data sources are created, please use childDataSourcesReady .

selectRecordById(id, record?)void

Select a record by ID. When select record by ID, we can pass in the record. So when the selected record is not loaded, we can add it in.

selectRecords(options)Promise<Pick<QueryResult"records">>

Select records.

selectRecordsByIds(ids, records?)void

Select records by IDs. When select records by IDs, we can pass in the records. So when the selected records are not loaded, we can add them in.

setCountStatus(status)void

Update data source count status.

setDataSourceJson(dsJson)void

Update data source JSON in data source instance

setListenSelection(listen)void

Whether listen selected records from other data sources which are derived from the same main data source. If true, will update selected record IDs of current data source info when selecting records via other derived data sources. Will also update selected record IDs when selecting records via current data source itself. If false, won't change selected record IDs when selecting records via other derived data sources. Will update selected record IDs only when selecting records via current data source itself.

setRecords(records)void

Update the records in the data source object only, does not update the source data.

setSourceRecords(records)void

When current data source is created from an array of records, will save it in sourceRecords . These two methods are used to update or get the source data.

setStatus(status)void

Update data source status.

updateSelectionInfo(options, triggerDataSource, forceCheck?)void

Update selected records in data source info if the current data source listens selection change (see setListenSelection ) or the current data source is the trigger data source (that is to say, select via it).

addSourceVersion

Interface Method
addSourceVersion(): void

When current data source is created from an array of records, it will be saved in sourceRecords . Add the version of sourceRecords . setSourceRecords will add the version by default.

Returns 
void

addVersion

optional
Interface Method
addVersion(): void

Update data source version.

Returns 
void

buildRecord

Interface Method
buildRecord(dataany): DataRecord

Builds a data record only -- does not add the record into data source.

Parameters
ParameterType
dataany
Returns 
DataRecord

clearRecords

optional
Interface Method
clearRecords(): void

This function will clear the loaded records and won't clear the sourceRecords. Once the loaded records are cleared, the version in the data source info will be updated.

Returns 
void

clearSourceRecords

Interface Method
clearSourceRecords(): void

Clear both sourceRecords and loaded records. Both source version and version in data source info will be updated.

Returns 
void

destroy

Interface Method
destroy(): void

Destroy the data source.

Returns 
void

fetchSchema

Interface Method
fetchSchema(): Promise<IMDataSourceSchema>

Fetch the data schema from an actual data source. If it's a statistic data source, the schema will not be fetched.

Returns 
Promise<IMDataSourceSchema>

getAllDerivedDataSources

Interface Method
getAllDerivedDataSources(): DataSource[]

Return the derived data views and local data sources.

Returns 
DataSource[]

getCountStatus

Interface Method
getCountStatus(): DataSourceStatus

Return data source count status.

Returns 
DataSourceStatus

getDataSourceJson

Interface Method
getDataSourceJson(): IMDataSourceJson

The data source JSON object in app config.

Returns 
IMDataSourceJson

getDataView

Interface Method
getDataView(dataViewIdstring): DataSource

Get data view by data view ID.

Parameters
ParameterType
dataViewIdstring
Returns 
DataSource

getDataViewConfig

Interface Method
getDataViewConfig(): IMDataViewJson

Return the config of the current data source.

Returns 
IMDataViewJson

getDataViews

Interface Method
getDataViews(): DataSource[]

Return all data views created from a main data source.

Returns 
DataSource[]

getIdField

Interface Method
getIdField(): string

Return the data source ID field.

Returns 
string

getInfo

Interface Method
getInfo(): IMDataSourceInfo

Return the data source info in redux store.

Returns 
IMDataSourceInfo

getLabel

Interface Method
getLabel(): string

Return data source label.

Returns 
string

getListenSelection

Interface Method
getListenSelection(): boolean

Return whether listen selection.

Returns 
boolean

getLocalDataSource

Interface Method
getLocalDataSource(localIdstring): DataSource

Get local data source by local ID.

Parameters
ParameterType
localIdstring
Returns 
DataSource

getLocalDataSources

Interface Method
getLocalDataSources(): DataSource[]

Return all local data sources created from a main data source or data view.

Returns 
DataSource[]

getMainDataSource

Interface Method
getMainDataSource(): DataSource

Return the main data source.

Returns 
DataSource

getRecordById

Interface Method
getRecordById(idstring): DataRecord

Get record by ID

Parameters
ParameterType
idstring
Returns 
DataRecord

getRecords

Interface Method
getRecords(): DataRecord[]

Get records

Returns 
DataRecord[]

getRecordsWithSelection

Interface Method
getRecordsWithSelection(): DataRecord[]

If selected records are not loaded in the current data source, they will be concatenated to the end of records array. For example, record 1 is selected in data view 1 and it is not loaded in data view 2 (record 1 actually matches query params of data view 2), dataView2.getRecordsWithSelection() will return all loaded records in data view 2 and record 1.

Returns 
DataRecord[]

getRootDataSource

Interface Method
getRootDataSource(): DataSource

Return the root data source.

Returns 
DataSource

getSchema

Interface Method
getSchema(): IMDataSourceSchema

The schema returned here is the merged result of the configured schema and the fetched schema. The configured schema is the user's changes, such as a new data source name. The fetched schema is the original schema from AGOL/portal item or a remote database, such as the service name, the fields and the filters.

Returns 
IMDataSourceSchema

getSelectedRecordIds

Interface Method
getSelectedRecordIds(): string[]

Get selected record IDs

Returns 
string[]

getSelectedRecordIndexes

Interface Method
getSelectedRecordIndexes(): number[]

Get selected record indexes

Returns 
number[]

getSelectedRecords

Interface Method
getSelectedRecords(): DataRecord[]

Get selected records

Returns 
DataRecord[]

getSelectionDataView

Interface Method
getSelectionDataView(): DataSource

Get selection data view

Returns 
DataSource

getSourceRecords

Interface Method
getSourceRecords(): DataRecord[]

Return the source records

Returns 
DataRecord[]

getSourceVersion

Interface Method
getSourceVersion(): number

When current data source is created from an array of records, it will be saved in sourceRecords . Return the version of sourceRecords .

Returns 
number

getStatus

Interface Method
getStatus(): DataSourceStatus

Return data source status.

Returns 
DataSourceStatus

getVersion

Interface Method
getVersion(): number

Return data source version.

Returns 
number

isDataSourceSet

Interface Method
isDataSourceSet(): thisisDataSource & SetDataSourceMixin

Whether a data source contains child data sources. A set data source won't create all its child data sources when ready is resolved. To make sure all child data sources are created, please use childDataSourcesReady .

Returns 
thisisDataSource & SetDataSourceMixin

isInAppConfig

Interface Method
isInAppConfig(): boolean

Return whether the data source is added in builder and is saved in app config.

Returns 
boolean

isSelectionView

Interface Method
isSelectionView(): boolean

Determine whether the data source is a selection view.

Returns 
boolean

ready

Interface Method
ready(): Promise<any>

Ready is resolved means the data source instance is ready for use. Please note that can not make sure all child data sources are created if a set data source is ready. To make sure all child data sources are created, please use childDataSourcesReady .

Returns 
Promise<any>

selectRecordById

Interface Method
selectRecordById(idstring, record?DataRecord): void

Select a record by ID. When select record by ID, we can pass in the record. So when the selected record is not loaded, we can add it in.

Parameters
ParameterTypeNotes
idstring

The ID to be selected. The selection will be cleared if the ID is null.

recordDataRecord
Returns 
void

selectRecords

Interface Method
selectRecords(optionsSelectOptions): Promise<Pick<QueryResult"records">>

Select records.

Parameters
ParameterType
optionsSelectOptions
Returns 
Promise<Pick<QueryResult"records">>

selectRecordsByIds

Interface Method
selectRecordsByIds(idsstring[], records?DataRecord[]): void

Select records by IDs. When select records by IDs, we can pass in the records. So when the selected records are not loaded, we can add them in.

Parameters
ParameterTypeNotes
idsstring[]

The IDs to be selected. The selection will be cleared if the IDs are null.

recordsDataRecord[]
Returns 
void

setCountStatus

optional
Interface Method
setCountStatus(statusDataSourceStatus): void

Update data source count status.

Parameters
ParameterType
statusDataSourceStatus
Returns 
void

setDataSourceJson

Interface Method
setDataSourceJson(dsJsonIMDataSourceJson): void

Update data source JSON in data source instance

Parameters
ParameterType
dsJsonIMDataSourceJson
Returns 
void

setListenSelection

Interface Method
setListenSelection(listenboolean): void

Whether listen selected records from other data sources which are derived from the same main data source. If true, will update selected record IDs of current data source info when selecting records via other derived data sources. Will also update selected record IDs when selecting records via current data source itself. If false, won't change selected record IDs when selecting records via other derived data sources. Will update selected record IDs only when selecting records via current data source itself.

Main data source and its data views will listen selected records by default, local data source does not listen selected records by default.

Parameters
ParameterType
listenboolean
Returns 
void

setRecords

Interface Method
setRecords(recordsDataRecord[]): void

Update the records in the data source object only, does not update the source data.

Parameters
ParameterType
recordsDataRecord[]
Returns 
void

setSourceRecords

Interface Method
setSourceRecords(recordsDataRecord[]): void

When current data source is created from an array of records, will save it in sourceRecords . These two methods are used to update or get the source data.

Parameters
ParameterType
recordsDataRecord[]
Returns 
void

setStatus

optional
Interface Method
setStatus(statusDataSourceStatus): void

Update data source status.

Parameters
ParameterType
statusDataSourceStatus
Returns 
void

updateSelectionInfo

Interface Method
updateSelectionInfo(optionsSelectOptions, triggerDataSourceDataSource, forceCheck?boolean): void

Update selected records in data source info if the current data source listens selection change (see setListenSelection ) or the current data source is the trigger data source (that is to say, select via it).

Before update info, will check whether these selected records match filters of the current data source firstly, and then only set the matched selected records to info. Will skip the check in some cases to improve performance if the forceCheck is not passed in or is false. For example, if the current data source is main data source (we suppose that main data source contains all records, no need to check). But if the forceCheck is true, won't skip the check.

Parameters
ParameterType
optionsSelectOptions
triggerDataSourceDataSource
forceCheckboolean
Returns 
void

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.