Interface
The DataSourceComponent component props.
Properties
| Property | Type | Notes |
|---|---|---|
children | ReactNode | DataRenderFunction | If one of your children component's render depends on data source, please use this render function. Otherwise, even if the data record in the data source is changed, your children will not be re-rendered unless you connect the data source info in the children owner component to re-render the owner component. |
errorString | string | If the creation of the data source fails, this string will be shown. |
forceRefreshVersion | number | Increment |
onAllChildDataSourcesCreated | (ds: DataSource) => void | Will call the function when all the child data sources are created. Please note the function is valid only when the current data source is data source set. |
onCreateDataSourceFailed | (err: any) => void | Will call the function when fail to create the data source. |
onDataSourceCreated | (ds: DataSource) => void | Will call the function when the data source is created. Please note that some child data sources may not have been created by the time the current data source is created. |
onDataSourceInfoChange | (info: IMDataSourceInfo, preInfo?: IMDataSourceInfo) => void | Will call the function when the data source info changes and on the component is mounted. |
onDataSourceSchemaChange | (schema: IMDataSourceSchema, prevSchema?: IMDataSourceSchema) => void | Will call the function when the data source schema changes. |
onDataSourceStatusChange | (status: DataSourceStatus, preStatus?: DataSourceStatus) => void | Will call the function when the data source status changes and on the component is mounted. |
onQueryRequired | (queryRequiredInfo: QueryRequiredInfo, preQueryRequiredInfo?: QueryRequiredInfo) => void | This callback is triggered whenever the data source properties such as filters or gdbVersion change, and on the component is mounted. For example, adding a filter to data source will trigger the callback and selecting a record won't. |
onSelectionChange | (selection: ImmutableArray<string>, preSelection?: ImmutableArray<string>) => void | Will call the function when the selected records change and on the component is mounted. |
query | QueryParams | Query parameters of queriable data source. The component does not execute a query without query property. To execute a query without adding new filter, please use an empty object: {}. |
queryAll | boolean | Whether to load all the records page by page or not.
Loading all records may take a long time and may cause performance issues. We recommend using the |
queryAllProgress | QueryProgressCallback | Only valid when |
queryAllSignal | AbortSignal | Only valid when |
queryCount | boolean | Whether load record count when loading data records or not. |
useDataSource | IMUseDataSource | Data source used by widget. Either |
widgetId | string | Pass widgetId/localId if need to execute the query. |
children
children: ReactNode | DataRenderFunctionIf one of your children component's render depends on data source, please use this render function. Otherwise, even if the data record in the data source is changed, your children will not be re-rendered unless you connect the data source info in the children owner component to re-render the owner component.
See here for the difference between parent and owner context: https://gist.github.com/jimfb/0eb6e61f300a8c1b2ce7.
errorString
errorString: stringIf the creation of the data source fails, this string will be shown.
forceRefreshVersion
forceRefreshVersion: numberIncrement forceRefreshVersion to force data source to load even if the query parameter does not change.
Please note, all widgets using the data source will refresh, too.
onAllChildDataSourcesCreated
onAllChildDataSourcesCreated: (ds: DataSource) => voidWill call the function when all the child data sources are created. Please note the function is valid only when the current data source is data source set.
Type declaration
function(ds: DataSource): voidParameters
| Parameter | Type |
|---|---|
ds | DataSource |
Returns
voidonCreateDataSourceFailed
onCreateDataSourceFailed: (err: any) => voidWill call the function when fail to create the data source.
Type declaration
function(err: any): voidParameters
| Parameter | Type |
|---|---|
err | any |
Returns
voidonDataSourceCreated
onDataSourceCreated: (ds: DataSource) => voidWill call the function when the data source is created. Please note that some child data sources may not have been created by the time the current data source is created.
Type declaration
function(ds: DataSource): voidParameters
| Parameter | Type |
|---|---|
ds | DataSource |
Returns
voidonDataSourceInfoChange
onDataSourceInfoChange: (info: IMDataSourceInfo, preInfo?: IMDataSourceInfo) => voidWill call the function when the data source info changes and on the component is mounted.
Type declaration
function(info: IMDataSourceInfo, preInfo?: IMDataSourceInfo): voidParameters
| Parameter | Type |
|---|---|
info | IMDataSourceInfo |
pre | IMDataSourceInfo |
Returns
voidonDataSourceSchemaChange
onDataSourceSchemaChange: (schema: IMDataSourceSchema, prevSchema?: IMDataSourceSchema) => voidWill call the function when the data source schema changes.
Type declaration
function(schema: IMDataSourceSchema, prevSchema?: IMDataSourceSchema): voidParameters
| Parameter | Type |
|---|---|
schema | IMDataSourceSchema |
prev | IMDataSourceSchema |
Returns
voidonDataSourceStatusChange
onDataSourceStatusChange: (status: DataSourceStatus, preStatus?: DataSourceStatus) => voidWill call the function when the data source status changes and on the component is mounted.
Type declaration
function(status: DataSourceStatus, preStatus?: DataSourceStatus): voidParameters
| Parameter | Type |
|---|---|
status | DataSourceStatus |
pre | DataSourceStatus |
Returns
voidonQueryRequired
onQueryRequired: (queryRequiredInfo: QueryRequiredInfo, preQueryRequiredInfo?: QueryRequiredInfo) => voidThis callback is triggered whenever the data source properties such as filters or gdbVersion change, and on the component is mounted. For example, adding a filter to data source will trigger the callback and selecting a record won't.
Please note this callback will be valid only when the query prop is not used.
Type declaration
function(queryRequiredInfo: QueryRequiredInfo, preQueryRequiredInfo?: QueryRequiredInfo): voidParameters
| Parameter | Type |
|---|---|
query | QueryRequiredInfo |
pre | QueryRequiredInfo |
Returns
voidonSelectionChange
onSelectionChange: (selection: ImmutableArray<string>, preSelection?: ImmutableArray<string>) => voidWill call the function when the selected records change and on the component is mounted.
The selection is shared between the main data source, data view, and local data source and local data view. So this callback will be invoked when selection is make on any of them.
Note that the local data source or local data view does not listen to the selection by default, you need to call setListenSelection(true)
to enable it when you need to.
Type declaration
function(selection: ImmutableArray<string>, preSelection?: ImmutableArray<string>): voidParameters
| Parameter | Type |
|---|---|
selection | ImmutableArray<string> |
pre | ImmutableArray<string> |
Returns
voidquery
query: QueryParamsQuery parameters of queriable data source. The component does not execute a query without query property. To execute a query without adding new filter, please use an empty object: {}.
queryAll
queryAll: booleanWhether to load all the records page by page or not.
Loading all records may take a long time and may cause performance issues. We recommend using the queryAllProgress and the queryAllSignal to show the progress and cancel the query if necessary.
queryAllProgress
queryAllProgress: QueryProgressCallbackOnly valid when queryAll is true.
The function is called when the query is in progress.
queryAllSignal
queryAllSignal: AbortSignalOnly valid when queryAll is true.
The signal object is used to communicate with the query requests.
See https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal for more information.
queryCount
queryCount: booleanWhether load record count when loading data records or not.
useDataSource
useDataSource: IMUseDataSourceData source used by widget. Either useDataSource or dataSource is required.
*
- If the used data source is configured in settings and is saved in widget json, please use
useDataSource. - If the used data source is added in runtime and is not saved in widget json, please use
dataSource. - If pass in both
useDataSourceanddataSource, will usedataSource.