diff --git a/packages/plugins/@tachybase/plugin-data-visualization/src/client/chart/antd/table.ts b/packages/plugins/@tachybase/plugin-data-visualization/src/client/chart/antd/table.ts index a9f17a659..05dc0bdfa 100644 --- a/packages/plugins/@tachybase/plugin-data-visualization/src/client/chart/antd/table.ts +++ b/packages/plugins/@tachybase/plugin-data-visualization/src/client/chart/antd/table.ts @@ -8,7 +8,7 @@ export class Table extends AntdChart { super({ name: 'table', title: 'Table', Component: AntdTable }); } - getProps({ data, fieldProps, general, advanced }: RenderProps) { + getProps({ data, fieldProps, general, advanced, ctx }: RenderProps) { const columns = data.length ? Object.keys(data[0]).map((item) => ({ title: fieldProps[item]?.label || item, @@ -33,7 +33,7 @@ export class Table extends AntdChart { item._key = index; return item; }); - const pageSize = advanced?.pagination?.pageSize || 10; + const pageSize = ctx.config?.pageSize || advanced?.pagination?.pageSize || 10; return { // bordered: true, size: 'middle', @@ -42,6 +42,9 @@ export class Table extends AntdChart { ? false : { pageSize, + onShowSizeChange: (curr, size) => { + ctx.config.setPageSize(size); + }, }, dataSource, columns, diff --git a/packages/plugins/@tachybase/plugin-data-visualization/src/client/renderer/ChartRendererProvider.tsx b/packages/plugins/@tachybase/plugin-data-visualization/src/client/renderer/ChartRendererProvider.tsx index 1b5a7fe1f..16f291ed1 100644 --- a/packages/plugins/@tachybase/plugin-data-visualization/src/client/renderer/ChartRendererProvider.tsx +++ b/packages/plugins/@tachybase/plugin-data-visualization/src/client/renderer/ChartRendererProvider.tsx @@ -1,4 +1,4 @@ -import React, { createContext, useContext } from 'react'; +import React, { createContext, useContext, useState } from 'react'; import { CollectionManagerProvider, DEFAULT_DATA_SOURCE_KEY, @@ -72,12 +72,14 @@ export const ChartRendererContext = createContext< ChartRendererContext.displayName = 'ChartRendererContext'; export const ChartRendererProvider: React.FC = (props) => { - const { query, config, collection, transform, dataSource = DEFAULT_DATA_SOURCE_KEY } = props; + const { query, config: propsConfig, collection, transform, dataSource = DEFAULT_DATA_SOURCE_KEY } = props; const { addChart } = useContext(ChartDataContext); const { ready, form, enabled } = useContext(ChartFilterContext); const { getFilter, hasFilter, appendFilter } = useChartFilter(); const schema = useFieldSchema(); const api = useAPIClient(); + const [pageSize, setPageSize] = useState(10); + const config = { pageSize, setPageSize, ...propsConfig }; const service = useRequest( (dataSource, collection, query, manual) => new Promise((resolve, reject) => {