Interface
The DataSourceComponent component props.
Properties
Property | Type | Notes |
---|---|---|
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. | |
number | Increment | |
(ds: DataSource) => void | ||
(err: any) => void | ||
(ds: DataSource) => void | ||
(info: IMDataSourceInfo, preInfo?: IMDataSourceInfo) => void | ||
(schema: IMDataSourceSchema, prevSchema?: IMDataSourceSchema) => void | ||
(status: DataSourceStatus, preStatus?: DataSourceStatus) => void | ||
(queryRequiredInfo: QueryRequiredInfo, preQueryRequiredInfo?: QueryRequiredInfo) => void | ||
(selection: ImmutableArray<string>, preSelection?: ImmutableArray<string>) => void | ||
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: {}. | ||
boolean | Whether query record count when query data records. | |
Data source used by widget. Either | ||
string | Pass widgetId/localId if need to execute the query. |
forceRefreshVersion
forceRefreshVersion: number
Increment 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) => void
Type declaration
function(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.
Parameters
Parameter | Type |
---|---|
ds | DataSource |
Returns
void
onCreateDataSourceFailed
onCreateDataSourceFailed: (err: any) => void
Type declaration
function(err: any): void
Will call the function when fail to create the data source.
Parameters
Parameter | Type |
---|---|
err | any |
Returns
void
onDataSourceCreated
onDataSourceCreated: (ds: DataSource) => void
Type declaration
function(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.
Parameters
Parameter | Type |
---|---|
ds | DataSource |
Returns
void
onDataSourceInfoChange
onDataSourceInfoChange: (info: IMDataSourceInfo, preInfo?: IMDataSourceInfo) => void
Type declaration
function(info: IMDataSourceInfo, preInfo?: IMDataSourceInfo): void
Will call the function when the data source info changes.
Parameters
Parameter | Type |
---|---|
info | IMDataSourceInfo |
pre | IMDataSourceInfo |
Returns
void
onDataSourceSchemaChange
onDataSourceSchemaChange: (schema: IMDataSourceSchema, prevSchema?: IMDataSourceSchema) => void
Type declaration
function(schema: IMDataSourceSchema, prevSchema?: IMDataSourceSchema): void
Will call the function when the data source schema changes.
Parameters
Parameter | Type |
---|---|
schema | IMDataSourceSchema |
prev | IMDataSourceSchema |
Returns
void
onDataSourceStatusChange
onDataSourceStatusChange: (status: DataSourceStatus, preStatus?: DataSourceStatus) => void
Type declaration
function(status: DataSourceStatus, preStatus?: DataSourceStatus): void
Will call the function when the data source status changes.
Parameters
Parameter | Type |
---|---|
status | DataSourceStatus |
pre | DataSourceStatus |
Returns
void
onQueryRequired
onQueryRequired: (queryRequiredInfo: QueryRequiredInfo, preQueryRequiredInfo?: QueryRequiredInfo) => void
Type declaration
function(queryRequiredInfo: QueryRequiredInfo, preQueryRequiredInfo?: QueryRequiredInfo): void
Widgets may not pass in query
props to load records into data source instance.
In this case, widgets still need to listen to data source changes to refresh themselves.
This callback is triggered whenever the data source properties such as filters or gdbVersion change.
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.
Parameters
Parameter | Type |
---|---|
query | QueryRequiredInfo |
pre | QueryRequiredInfo |
Returns
void
onSelectionChange
onSelectionChange: (selection: ImmutableArray<string>, preSelection?: ImmutableArray<string>) => void
Type declaration
function(selection: ImmutableArray<string>, preSelection?: ImmutableArray<string>): void
Will call the function when the selected records change.
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.
Parameters
Parameter | Type |
---|---|
selection | ImmutableArray<string> |
pre | ImmutableArray<string> |
Returns
void
query
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: {}.
queryCount
queryCount: boolean
Whether query record count when query data records.
useDataSource
useDataSource: IMUseDataSource
Data 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
useDataSource
anddataSource
, will usedataSource
.
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.
See here for the difference between parent and owner context: https://gist.github.com/jimfb/0eb6e61f300a8c1b2ce7.