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
Property | Type | Notes |
---|---|---|
() => void | When current data source is created from an array of records, it will be saved in | |
() => void | Update data source version. | |
The data source which this data source derives from. | ||
(data: any) => DataRecord | Builds a data record only -- does not add the record into data source. | |
() => 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. | |
() => void | Clear both sourceRecords and loaded records. Both source version and version in data source info will be updated. | |
number | The total records count depends on the current query | |
The data source manager, which is used to manage the data source, including create/get/destroy the data source instance. | ||
string | The data view ID configured in JSON. | |
() => void | Destroy the data source. | |
() => Promise<IMDataSourceSchema> | Fetch the data schema from an actual data source. If it's a statistic data source, the schema will not be fetched. | |
() => DataSource[] | Return the derived data views and local data sources. | |
() => DataSourceStatus | Return data source count status. | |
() => IMDataSourceJson | The data source JSON object in app config. | |
(dataViewId: string) => DataSource | Get data view by data view ID. | |
() => IMDataViewJson | Return the config of the current data source. | |
() => DataSource[] | Return all data views created from a main data source. | |
() => string | Return the data source ID field. | |
() => IMDataSourceInfo | Return the data source info in redux store. | |
() => string | Return data source label. | |
() => boolean | Return whether listen selection. | |
(localId: string) => DataSource | Get local data source by local ID. | |
() => DataSource[] | Return all local data sources created from a main data source or data view. | |
() => DataSource | Return the main data source. | |
(index: number) => DataRecord | Get record by index | |
(id: string) => DataRecord | Get record by ID | |
() => DataRecord[] | Get records | |
() => 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. | |
() => DataSource | Return the root data source. | |
() => 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. | |
() => string[] | Get selected record IDs | |
() => number[] | Get selected record indexes | |
() => DataRecord[] | Get selected records | |
() => DataSource | Get selection data view | |
() => DataRecord[] | Return the source records | |
() => number | When current data source is created from an array of records, it will be saved in | |
() => DataSourceStatus | Return data source status. | |
() => number | Return data source version. | |
string | The data source ID. | |
() => thisisDataSource & SetDataSourceMixin | Whether a data source contains child data sources.
A set data source won't create all its child data sources when | |
boolean | 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. | |
() => boolean | Return whether the data source is added in builder and is saved in app config. | |
boolean | True means the data source is a local data source. | |
string | The local ID of the data source. | |
number | Order in the parent data source. | |
DataSource & SetDataSourceMixin | The parent data source of this data source, mull means it's a root data source. | |
() => 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 | |
(id: string, 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. | |
(options: SelectOptions) => Promise<Pick<QueryResult, "records">> | Select records. | |
(ids: string[], 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. | |
(status: DataSourceStatus) => void | Update data source count status. | |
(dsJson: IMDataSourceJson) => void | Update data source JSON in data source instance | |
(listen: boolean) => 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. | |
(records: DataRecord[]) => void | Update the records in the data source object only, does not update the source data. | |
(records: DataRecord[]) => void | When current data source is created from an array of records, will save it in | |
(status: DataSourceStatus) => void | Update data source status. | |
string | The type of the data source. | |
(options: SelectOptions, triggerDataSource: DataSource, forceCheck?: boolean) => void | Update selected records in data source info if the current data source listens selection change (see |
addSourceVersion
Interface PropertyaddSourceVersion: () => 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.
Type declaration
function(): void
Returns
void
addVersion
addVersion: () => void
Update data source version.
Type declaration
function(): void
Returns
void
belongToDataSource
belongToDataSource: DataSource
The data source which this data source derives from.
buildRecord
Interface PropertybuildRecord: (data: any) => DataRecord
Builds a data record only -- does not add the record into data source.
Type declaration
function(data: any): DataRecord
Parameters
Parameter | Type |
---|---|
data | any |
Returns
DataRecord
clearRecords
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.
Type declaration
function(): void
Returns
void
clearSourceRecords
Interface PropertyclearSourceRecords: () => void
Clear both sourceRecords and loaded records. Both source version and version in data source info will be updated.
Type declaration
function(): void
Returns
void
dataSourceManager
Interface PropertydataSourceManager: DataSourceManager
The data source manager, which is used to manage the data source, including create/get/destroy the data source instance.
destroy
Interface Propertydestroy: () => void
Destroy the data source.
Type declaration
function(): void
Returns
void
fetchSchema
Interface PropertyfetchSchema: () => Promise<IMDataSourceSchema>
Fetch the data schema from an actual data source. If it's a statistic data source, the schema will not be fetched.
Type declaration
function(): Promise<IMDataSourceSchema>
Returns
Promise<IMDataSourceSchema>
getAllDerivedDataSources
Interface PropertygetAllDerivedDataSources: () => DataSource[]
Return the derived data views and local data sources.
Type declaration
function(): DataSource[]
Returns
DataSource[]
getCountStatus
Interface PropertygetCountStatus: () => DataSourceStatus
Return data source count status.
Type declaration
function(): DataSourceStatus
Returns
DataSourceStatus
getDataSourceJson
Interface PropertygetDataSourceJson: () => IMDataSourceJson
The data source JSON object in app config.
Type declaration
function(): IMDataSourceJson
Returns
IMDataSourceJson
getDataView
Interface PropertygetDataView: (dataViewId: string) => DataSource
Get data view by data view ID.
Type declaration
function(dataViewId: string): DataSource
Parameters
Parameter | Type |
---|---|
data | string |
Returns
DataSource
getDataViewConfig
Interface PropertygetDataViewConfig: () => IMDataViewJson
Return the config of the current data source.
Type declaration
function(): IMDataViewJson
Returns
IMDataViewJson
getDataViews
Interface PropertygetDataViews: () => DataSource[]
Return all data views created from a main data source.
Type declaration
function(): DataSource[]
Returns
DataSource[]
getIdField
Interface PropertygetIdField: () => string
Return the data source ID field.
Type declaration
function(): string
Returns
string
getInfo
Interface PropertygetInfo: () => IMDataSourceInfo
Return the data source info in redux store.
Type declaration
function(): IMDataSourceInfo
Returns
IMDataSourceInfo
getLabel
Interface PropertygetLabel: () => string
Return data source label.
Type declaration
function(): string
Returns
string
getListenSelection
Interface PropertygetListenSelection: () => boolean
Return whether listen selection.
Type declaration
function(): boolean
Returns
boolean
getLocalDataSource
Interface PropertygetLocalDataSource: (localId: string) => DataSource
Get local data source by local ID.
Type declaration
function(localId: string): DataSource
Parameters
Parameter | Type |
---|---|
local | string |
Returns
DataSource
getLocalDataSources
Interface PropertygetLocalDataSources: () => DataSource[]
Return all local data sources created from a main data source or data view.
Type declaration
function(): DataSource[]
Returns
DataSource[]
getMainDataSource
Interface PropertygetMainDataSource: () => DataSource
Return the main data source.
Type declaration
function(): DataSource
Returns
DataSource
getRecord
Interface PropertygetRecord: (index: number) => DataRecord
Get record by index
Type declaration
function(index: number): DataRecord
Parameters
Parameter | Type |
---|---|
index | number |
Returns
DataRecord
getRecordById
Interface PropertygetRecordById: (id: string) => DataRecord
Get record by ID
Type declaration
function(id: string): DataRecord
Parameters
Parameter | Type |
---|---|
id | string |
Returns
DataRecord
getRecords
Interface PropertygetRecords: () => DataRecord[]
Get records
Type declaration
function(): DataRecord[]
Returns
DataRecord[]
getRecordsWithSelection
Interface PropertygetRecordsWithSelection: () => 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.
Type declaration
function(): DataRecord[]
Returns
DataRecord[]
getRootDataSource
Interface PropertygetRootDataSource: () => DataSource
Return the root data source.
Type declaration
function(): DataSource
Returns
DataSource
getSchema
Interface PropertygetSchema: () => 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.
Type declaration
function(): IMDataSourceSchema
Returns
IMDataSourceSchema
getSelectedRecordIds
Interface PropertygetSelectedRecordIds: () => string[]
Get selected record IDs
Type declaration
function(): string[]
Returns
string[]
getSelectedRecordIndexes
Interface PropertygetSelectedRecordIndexes: () => number[]
Get selected record indexes
Type declaration
function(): number[]
Returns
number[]
getSelectedRecords
Interface PropertygetSelectedRecords: () => DataRecord[]
Get selected records
Type declaration
function(): DataRecord[]
Returns
DataRecord[]
getSelectionDataView
Interface PropertygetSelectionDataView: () => DataSource
Get selection data view
Type declaration
function(): DataSource
Returns
DataSource
getSourceRecords
Interface PropertygetSourceRecords: () => DataRecord[]
Return the source records
Type declaration
function(): DataRecord[]
Returns
DataRecord[]
getSourceVersion
Interface PropertygetSourceVersion: () => number
When current data source is created from an array of records, it will be saved in sourceRecords
.
Return the version of sourceRecords
.
Type declaration
function(): number
Returns
number
getStatus
Interface PropertygetStatus: () => DataSourceStatus
Return data source status.
Type declaration
function(): DataSourceStatus
Returns
DataSourceStatus
getVersion
Interface PropertygetVersion: () => number
Return data source version.
Type declaration
function(): number
Returns
number
isDataSourceSet
Interface PropertyisDataSourceSet: () => 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
.
Type declaration
function(): thisisDataSource & SetDataSourceMixin
Returns
thisisDataSource & SetDataSourceMixin
isDataView
Interface PropertyisDataView: boolean
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.
isInAppConfig
Interface PropertyisInAppConfig: () => boolean
Return whether the data source is added in builder and is saved in app config.
Type declaration
function(): boolean
Returns
boolean
parentDataSource
Interface PropertyparentDataSource: DataSource & SetDataSourceMixin
The parent data source of this data source, mull means it's a root data source.
ready
Interface Propertyready: () => 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
.
Type declaration
function(): Promise<any>
Returns
Promise<any>
selectRecordById
Interface PropertyselectRecordById: (id: string, 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.
Type declaration
function(id: string, record?: DataRecord): void
Parameters
Parameter | Type | Notes |
---|---|---|
id | string | The ID to be selected. The selection will be cleared if the ID is null. |
record | DataRecord |
Returns
void
selectRecords
Interface PropertyselectRecords: (options: SelectOptions) => Promise<Pick<QueryResult, "records">>
Select records.
Type declaration
function(options: SelectOptions): Promise<Pick<QueryResult, "records">>
Parameters
Parameter | Type |
---|---|
options | SelectOptions |
Returns
Promise<Pick<QueryResult, "records">>
selectRecordsByIds
Interface PropertyselectRecordsByIds: (ids: string[], 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.
Type declaration
function(ids: string[], records?: DataRecord[]): void
Parameters
Parameter | Type | Notes |
---|---|---|
ids | string[] | The IDs to be selected. The selection will be cleared if the IDs are null. |
records | DataRecord[] |
Returns
void
setCountStatus
setCountStatus: (status: DataSourceStatus) => void
Update data source count status.
Type declaration
function(status: DataSourceStatus): void
Parameters
Parameter | Type |
---|---|
status | DataSourceStatus |
Returns
void
setDataSourceJson
Interface PropertysetDataSourceJson: (dsJson: IMDataSourceJson) => void
Update data source JSON in data source instance
Type declaration
function(dsJson: IMDataSourceJson): void
Parameters
Parameter | Type |
---|---|
ds | IMDataSourceJson |
Returns
void
setListenSelection
Interface PropertysetListenSelection: (listen: boolean) => 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.
Type declaration
function(listen: boolean): void
Parameters
Parameter | Type |
---|---|
listen | boolean |
Returns
void
setRecords
Interface PropertysetRecords: (records: DataRecord[]) => void
Update the records in the data source object only, does not update the source data.
Type declaration
function(records: DataRecord[]): void
Parameters
Parameter | Type |
---|---|
records | DataRecord[] |
Returns
void
setSourceRecords
Interface PropertysetSourceRecords: (records: DataRecord[]) => 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.
Type declaration
function(records: DataRecord[]): void
Parameters
Parameter | Type |
---|---|
records | DataRecord[] |
Returns
void
setStatus
setStatus: (status: DataSourceStatus) => void
Update data source status.
Type declaration
function(status: DataSourceStatus): void
Parameters
Parameter | Type |
---|---|
status | DataSourceStatus |
Returns
void
updateSelectionInfo
Interface PropertyupdateSelectionInfo: (options: SelectOptions, triggerDataSource: DataSource, 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.
Type declaration
function(options: SelectOptions, triggerDataSource: DataSource, forceCheck?: boolean): void
Parameters
Parameter | Type |
---|---|
options | SelectOptions |
trigger | DataSource |
force | boolean |
Returns
void