fix: 修复图表页面设置分页无效 (#1257)
Co-authored-by: sealday <zhanglin@daoyoucloud.com> Reviewed-on: daoyoucloud/tachybase#1257 Reviewed-by: sealday <zhanglin@daoyoucloud.com> Co-authored-by: wjh <wwwjh0710@163.com> Co-committed-by: wjh <wwwjh0710@163.com>
This commit is contained in:
parent
2db816a872
commit
304daf4ac0
@ -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,
|
||||
|
@ -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<ChartRendererProps> = (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) => {
|
||||
|
Loading…
Reference in New Issue
Block a user