pagination prop for antd table

元气小坏坏 提交于 2020-06-14 07:35:11

问题


I am using Table component from antd library. I want to pass pagination prop to the Table component. In the docs it says pass the pagination config object which refers to the Pagination component itself.

So I am passing the pagination object using Pagination component prop names as keys like <Table pagination={{pageSizeOptions : ['30', '40'], showPageSizeOptions : true}} {...otherProps} />

But when I inspect the Table component in react-inspector I don't see the pagination prop in component props but it is there in the component state and has default values.

How to use the pagination prop for Table component?


回答1:


Replace "showPageSizeOptions" to "showSizeChanger".

i.e.

<Table pagination= { {pageSizeOptions: ['30', '40'], showSizeChanger: true}} rowSelection={rowSelection} columns={columns} dataSource={data} />



回答2:


creating a pagination config object and using it with object spread syntax worked!

config = { pagination : { pageSizeOptions : ['30', '40'], showSizeChanger : true } }

<Table {...config} {...otherProps} />

It worked but don't understand the why and what is the difference between the two semantics of the two syntax.



来源:https://stackoverflow.com/questions/49206995/pagination-prop-for-antd-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!