最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - pagination prop for antd table - Stack Overflow

programmeradmin8浏览0评论

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?

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?

Share Improve this question asked Mar 10, 2018 at 8:29 gamedev90gamedev90 1011 gold badge1 silver badge11 bronze badges 2
  • I am using antd 3.2.1 – gamedev90 Commented Mar 10, 2018 at 9:25
  • I found this article very useful blog.emiketic.com/2018/… – Amol Wankhede Commented Dec 30, 2018 at 5:39
Add a comment  | 

2 Answers 2

Reset to default 11

Replace "showPageSizeOptions" to "showSizeChanger".

i.e.

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

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.

发布评论

评论列表(0)

  1. 暂无评论