Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

antd - ant design table with pagination control supporting a widget to choose rows per page?

Does the Ant Design Table controller take a Pagination component, instead of a plain object of properties. I need to add a switcher, to switch between rows per page.

Currently it is implemented in the Pagination component.

like image 971
Aadhi Vive Avatar asked Aug 14 '18 20:08

Aadhi Vive


People also ask

How do I select rows in ANTD table?

Rows can be selectable by making first column as a selectable column. You can use rowSelection.type to set selection type. Default is checkbox . selection happens when clicking checkbox by default.

How do I make an ANTD table responsive?

You can make use of the responsive property on the column that you want to control for screen sizes. Just add a From To column with a custom render function, and set the responsive property on that column to only show on xs screens. The From and To columns will have the responsive property set to show on md and above.


1 Answers

If what you need is only the ability to select the number of rows per page, then the following code should work for you:

<Table
    dataSource={...}
    pagination={{ defaultPageSize: 10, showSizeChanger: true, pageSizeOptions: ['10', '20', '30']}}
>

Basically wrapping the Pagination props into a pagination object, and pass it into your Table component.

If you need more customization you might want to consider turning the default Table pagination off and hook up your custom pagination component. Sample code:

Edit nervous-jennings-iw5l6

like image 96
Yu Chia Wu Avatar answered Sep 20 '22 12:09

Yu Chia Wu