DataSourceComponent

DataSourceComponent

Function
DataSourceComponent(props{ children?: ReactNode | DataRenderFunction; dataSource?: DataSource; errorString?: string; forceRefreshVersion?: number; localId?: string; onAllChildDataSourcesCreated?: (dsDataSource) => void; onCreateDataSourceFailed?: (errany) => void; onDataSourceCreated?: (dsDataSource) => void; onDataSourceInfoChange?: (infoIMDataSourceInfo, preInfo?IMDataSourceInfo) => void; onDataSourceSchemaChange?: (schemaIMDataSourceSchema, prevSchema?IMDataSourceSchema) => void; onDataSourceStatusChange?: (statusDataSourceStatus, preStatus?DataSourceStatus) => void; onQueryRequired?: (queryRequiredInfoQueryRequiredInfo, preQueryRequiredInfo?QueryRequiredInfo) => void; onSelectionChange?: (selectionImmutableArray<string>, preSelection?ImmutableArray<string>) => void; query?: QueryParams; queryCount?: boolean; queryScope?: QueryScope; useDataSource?: ImmutableObjectMixin<UseDataSource> & { dataSourceId: string; dataViewId?: string; fields?: ImmutableArray<string>; mainDataSourceId: string; rootDataSourceId?: string; useFieldsInPopupInfo?: boolean; useFieldsInSymbol?: boolean }; widgetId?: string }, context?any): ReactNode

A react component that makes data source easy to use. It helps widgets to create data source instance, load records and listen changes of data source. In most cases, you can pass in useDataSource and query , and render the query result by using a render function as a child component. The query result records are put into data source records property (Internally, it calls load() method).

Use dark colors for code blocksCopy
1
<DataSourceComponent useDataSource={props.useDataSources[0]} onDataSourceCreated={handleDataSourceCreated} onCreateDataSourceFailed={handleDataSourceFailed} onDataSourceInfoChange={handleDataSourceChange} />
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
const renderData = (ds: DataSource, info: IMDataSourceInfo) => {
return <div>
{
  ds && ds.getRecords().map(r => <div>{r.getId()}</div>)
}
</div>
}
<DataSourceComponent widgetId={props.id} query={{ where: '1=1' }} useDataSource={props.useDataSources[0]}>{renderData}</DataSourceComponent>
Parameters
ParameterType
props
{ children?: ReactNode | DataRenderFunction; dataSource?: DataSource; errorString?: string; forceRefreshVersion?: number; localId?: string; onAllChildDataSourcesCreated?: (dsDataSource) => void; onCreateDataSourceFailed?: (errany) => void; onDataSourceCreated?: (dsDataSource) => void; onDataSourceInfoChange?: (infoIMDataSourceInfo, preInfo?IMDataSourceInfo) => void; onDataSourceSchemaChange?: (schemaIMDataSourceSchema, prevSchema?IMDataSourceSchema) => void; onDataSourceStatusChange?: (statusDataSourceStatus, preStatus?DataSourceStatus) => void; onQueryRequired?: (queryRequiredInfoQueryRequiredInfo, preQueryRequiredInfo?QueryRequiredInfo) => void; onSelectionChange?: (selectionImmutableArray<string>, preSelection?ImmutableArray<string>) => void; query?: QueryParams; queryCount?: boolean; queryScope?: QueryScope; useDataSource?: ImmutableObjectMixin<UseDataSource> & { dataSourceId: string; dataViewId?: string; fields?: ImmutableArray<string>; mainDataSourceId: string; rootDataSourceId?: string; useFieldsInPopupInfo?: boolean; useFieldsInSymbol?: boolean }; widgetId?: string }
context
any
Returns 
ReactNode

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