question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The documentation about to use pagination on Table is confuse

See original GitHub issue
  • I have searched the issues of this repository and believe that this is not a duplicate.

What problem does this feature solve?

Better understanding about the documentation.

What does the proposed API look like?

Add a better documentation about how to use Table with Pagination.

Based on the documentation I thought that it would be possible to create an external custom Pagination component and then hook it up into Table but it seems that this is not possible:

<Table
          columns={columns}
          dataSource={clients}
          pagination={<ConnectedPagination />} or pagination={ConnectedPagination} 
        />

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
FullStackDeveloper2020commented, Feb 8, 2020

“You can directly set pagination={false} and customize table component”. How can i add my own custom pagination to antd Table. i didn’t understand that…

4reactions
EugenEistrachcommented, Mar 14, 2020

@FullStackDeveloper2020 I created the following hook (keep in mind this is typescript)

import { Dispatch, SetStateAction, useState } from "react";

const usePagination = <T>(
  data: T[],
  initialSize = 10,
  initialPage = 1
): [
  T[],
  number,
  Dispatch<SetStateAction<number>>,
  number,
  Dispatch<SetStateAction<number>>
] => {
  const [pageSize, setPageSize] = useState(initialSize);
  const [currentPage, setCurrentPage] = useState(initialPage);

  const paginatedData = data.slice(
    (currentPage - 1) * pageSize,
    (currentPage - 1) * pageSize + pageSize
  ) as T[];

  return [paginatedData, currentPage, setCurrentPage, pageSize, setPageSize];
};

export default usePagination;

And am using it like this:

const PublisherPage = () => {
  const dispatch = useDispatch();
  const publishers = usePublishers();
  const isFetching = useIsFetchingPublisher();
  const [
    paginatedPublishers,
    currentPage,
    setCurrentPage,
    pageSize
  ] = usePagination(publishers);

  useEffect(() => {
    dispatch(getAllPublishersAsync());
  }, []);

  return (
    <>
      <PageHeader
        title="Publisher"
        subTitle="Manage all publishers"
        extra={[
          <Pagination
            key={"pagination"}
            current={currentPage}
            onChange={setCurrentPage}
            pageSize={pageSize}
            total={publishers.length}
            size="small"
          />
        ]}
      />

      <Table
        css={tableCss}
        dataSource={paginatedPublishers}
        columns={columns}
        rowKey="id"
        size="small"
        bordered
        pagination={false}
        tableLayout="fixed"
        loading={isFetching}
      />
    </>
  );
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I put a table pagination at the bottom of the table?
I tried putting the <TablePagination> inside <TableFooter> and it still did not work. However, I found a work around using Flex:
Read more >
Solved: How can I add pagination to a Dashboard Panel?
Solved: I have a number of panels on a dashboard that contain data tables with a large number of results. For some reason...
Read more >
HTML Table with Pagination - YouTube
In this video, we will create a table with pagination and load the table with cryptocurrency data using the coinlore api.
Read more >
Pagination – Examples And Good Practices
Good Practices Of Pagination Design # · Provide large clickable areas · Don't use underlines · Identify the current page · Space out...
Read more >
How to Do Pagination in Tableau | Playfair Data
If you skipped straight to this use case of using pagination with comments, you would need to ensure a parameter action is in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found