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. | |
string | If the creation of the data source fails, this string will be shown. | |
number | Increment | |
(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. | |
(err: any) => void | Will call the function when fail to create the data source. | |
(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. | |
(info: IMDataSourceInfo, preInfo?: IMDataSourceInfo) => void | Will call the function when the data source info changes and on the component is mounted. | |
(schema: IMDataSourceSchema, prevSchema?: IMDataSourceSchema) => void | Will call the function when the data source schema changes. | |
(status: DataSourceStatus, preStatus?: DataSourceStatus) => void | Will call the function when the data source status changes and on the component is mounted. | |
(queryRequiredInfo: QueryRequiredInfo, preQueryRequiredInfo?: QueryRequiredInfo) => void | Widgets may not pass in | |
(selection: ImmutableArray<string>, preSelection?: ImmutableArray<string>) => void | Will call the function when the selected records change and on the component is mounted. | |
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. |
children
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.
errorString
errorString: string
If the creation of the data source fails, this string will be shown.
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
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.
Type declaration
function(ds: DataSource): void
Parameters
Parameter | Type |
---|---|
ds | DataSource |
Returns
void
onCreateDataSourceFailed
onCreateDataSourceFailed: (err: any) => void
Will call the function when fail to create the data source.
Type declaration
function(err: any): void
Parameters
Parameter | Type |
---|---|
err | any |
Returns
void
onDataSourceCreated
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.
Type declaration
function(ds: DataSource): void
Parameters
Parameter | Type |
---|---|
ds | DataSource |
Returns
void
onDataSourceInfoChange
onDataSourceInfoChange: (info: IMDataSourceInfo, preInfo?: IMDataSourceInfo) => void
Will call the function when the data source info changes and on the component is mounted.
Type declaration
function(info: IMDataSourceInfo, preInfo?: IMDataSourceInfo): void
Parameters
Parameter | Type |
---|---|
info | IMDataSourceInfo |
pre | IMDataSourceInfo |
Returns
void
onDataSourceSchemaChange
onDataSourceSchemaChange: (schema: IMDataSourceSchema, prevSchema?: IMDataSourceSchema) => void
Will call the function when the data source schema changes.
Type declaration
function(schema: IMDataSourceSchema, prevSchema?: IMDataSourceSchema): void
Parameters
Parameter | Type |
---|---|
schema | IMDataSourceSchema |
prev | IMDataSourceSchema |
Returns
void
onDataSourceStatusChange
onDataSourceStatusChange: (status: DataSourceStatus, preStatus?: DataSourceStatus) => void
Will call the function when the data source status changes and on the component is mounted.
Type declaration
function(status: DataSourceStatus, preStatus?: DataSourceStatus): void
Parameters
Parameter | Type |
---|---|
status | DataSourceStatus |
pre | DataSourceStatus |
Returns
void
onQueryRequired
onQueryRequired: (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, 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): void
Parameters
Parameter | Type |
---|---|
query | QueryRequiredInfo |
pre | QueryRequiredInfo |
Returns
void
onSelectionChange
onSelectionChange: (selection: ImmutableArray<string>, preSelection?: ImmutableArray<string>) => void
Will 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>): void
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
.