Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/pluggableWidgets/datagrid-web/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

### Added

- We added _Refresh time_ setting to Datagrid, this allows automatic data refresh.

### Changed

- We improved structure preview of the widget in Studio Pro 9.20 and above.
Expand Down
8 changes: 8 additions & 0 deletions packages/pluggableWidgets/datagrid-web/src/Datagrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ export default function Datagrid(props: DatagridContainerProps): ReactElement {
}
}, [props.datasource, props.configurationAttribute, filtered]);

useEffect(() => {
if (props.refreshInterval > 0) {
setTimeout(() => {
props.datasource.reload();
}, props.refreshInterval * 1000);
}
}, [props.datasource, props.refreshInterval]);

const setPage = useCallback(
computePage => {
const newPage = computePage(currentPage);
Expand Down
4 changes: 4 additions & 0 deletions packages/pluggableWidgets/datagrid-web/src/Datagrid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
<caption>Data source</caption>
<description />
</property>
<property key="refreshInterval" type="integer" defaultValue="0">
<caption>Refresh time (in seconds)</caption>
<description />
</property>
</propertyGroup>
<propertyGroup caption="Columns">
<property key="columns" type="object" isList="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export interface DatagridContainerProps {
tabIndex?: number;
advanced: boolean;
datasource: ListValue;
refreshInterval: number;
columns: ColumnsType[];
columnsFilterable: boolean;
pageSize: number;
Expand Down Expand Up @@ -105,6 +106,7 @@ export interface DatagridPreviewProps {
readOnly: boolean;
advanced: boolean;
datasource: {} | { type: string } | null;
refreshInterval: number | null;
columns: ColumnsPreviewType[];
columnsFilterable: boolean;
pageSize: number | null;
Expand Down