Client: Perform pagination using AntD instead
If we let Refine do the pagination, it will only return a page's worth of items in the dataSource. This makes the sorting useless if the items span multiple pages. Now we let Ant Design to the pagination instead.
This commit is contained in:
@@ -19,10 +19,9 @@ dayjs.extend(utc);
|
|||||||
|
|
||||||
export const FilamentList: React.FC<IResourceComponentsProps> = () => {
|
export const FilamentList: React.FC<IResourceComponentsProps> = () => {
|
||||||
const { tableProps, sorters } = useTable<IFilament>({
|
const { tableProps, sorters } = useTable<IFilament>({
|
||||||
syncWithLocation: true,
|
syncWithLocation: false,
|
||||||
pagination: {
|
pagination: {
|
||||||
mode: "client",
|
mode: "off", // Perform pagination in antd's Table instead. Otherwise client-side sorting/filtering doesn't work.
|
||||||
pageSize: 20,
|
|
||||||
},
|
},
|
||||||
sorters: {
|
sorters: {
|
||||||
mode: "off", // Disable server-side sorting
|
mode: "off", // Disable server-side sorting
|
||||||
@@ -43,7 +42,12 @@ export const FilamentList: React.FC<IResourceComponentsProps> = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<List>
|
<List>
|
||||||
<Table {...tableProps} dataSource={dataSource} rowKey="id">
|
<Table
|
||||||
|
{...tableProps}
|
||||||
|
dataSource={dataSource}
|
||||||
|
pagination={{ showSizeChanger: true, pageSize: 20 }}
|
||||||
|
rowKey="id"
|
||||||
|
>
|
||||||
<Table.Column
|
<Table.Column
|
||||||
dataIndex="id"
|
dataIndex="id"
|
||||||
title="Id"
|
title="Id"
|
||||||
|
|||||||
@@ -19,10 +19,9 @@ dayjs.extend(utc);
|
|||||||
|
|
||||||
export const SpoolList: React.FC<IResourceComponentsProps> = () => {
|
export const SpoolList: React.FC<IResourceComponentsProps> = () => {
|
||||||
const { tableProps, sorters } = useTable({
|
const { tableProps, sorters } = useTable({
|
||||||
syncWithLocation: true,
|
syncWithLocation: false,
|
||||||
pagination: {
|
pagination: {
|
||||||
mode: "client",
|
mode: "off", // Perform pagination in antd's Table instead. Otherwise client-side sorting/filtering doesn't work.
|
||||||
pageSize: 20,
|
|
||||||
},
|
},
|
||||||
sorters: {
|
sorters: {
|
||||||
mode: "off", // Disable server-side sorting
|
mode: "off", // Disable server-side sorting
|
||||||
@@ -52,7 +51,12 @@ export const SpoolList: React.FC<IResourceComponentsProps> = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<List>
|
<List>
|
||||||
<Table {...tableProps} dataSource={dataSource} rowKey="id">
|
<Table
|
||||||
|
{...tableProps}
|
||||||
|
dataSource={dataSource}
|
||||||
|
pagination={{ showSizeChanger: true, pageSize: 20 }}
|
||||||
|
rowKey="id"
|
||||||
|
>
|
||||||
<Table.Column
|
<Table.Column
|
||||||
dataIndex="id"
|
dataIndex="id"
|
||||||
title="Id"
|
title="Id"
|
||||||
|
|||||||
12
client/src/pages/vendors/list.tsx
vendored
12
client/src/pages/vendors/list.tsx
vendored
@@ -17,10 +17,9 @@ dayjs.extend(utc);
|
|||||||
|
|
||||||
export const VendorList: React.FC<IResourceComponentsProps> = () => {
|
export const VendorList: React.FC<IResourceComponentsProps> = () => {
|
||||||
const { tableProps, sorters } = useTable({
|
const { tableProps, sorters } = useTable({
|
||||||
syncWithLocation: true,
|
syncWithLocation: false,
|
||||||
pagination: {
|
pagination: {
|
||||||
mode: "client",
|
mode: "off", // Perform pagination in antd's Table instead. Otherwise client-side sorting/filtering doesn't work.
|
||||||
pageSize: 20,
|
|
||||||
},
|
},
|
||||||
sorters: {
|
sorters: {
|
||||||
mode: "off", // Disable server-side sorting
|
mode: "off", // Disable server-side sorting
|
||||||
@@ -41,13 +40,18 @@ export const VendorList: React.FC<IResourceComponentsProps> = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<List>
|
<List>
|
||||||
<Table {...tableProps} dataSource={dataSource} rowKey="id">
|
|
||||||
<Table.Column
|
<Table.Column
|
||||||
dataIndex="id"
|
dataIndex="id"
|
||||||
title="Id"
|
title="Id"
|
||||||
sorter={true}
|
sorter={true}
|
||||||
defaultSortOrder="ascend"
|
defaultSortOrder="ascend"
|
||||||
/>
|
/>
|
||||||
|
<Table
|
||||||
|
{...tableProps}
|
||||||
|
dataSource={dataSource}
|
||||||
|
pagination={{ showSizeChanger: true, pageSize: 20 }}
|
||||||
|
rowKey="id"
|
||||||
|
>
|
||||||
<Table.Column dataIndex="name" title="Name" sorter={true} />
|
<Table.Column dataIndex="name" title="Name" sorter={true} />
|
||||||
<Table.Column
|
<Table.Column
|
||||||
dataIndex={["registered"]}
|
dataIndex={["registered"]}
|
||||||
|
|||||||
Reference in New Issue
Block a user