Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set the antd table page size in reactjs

Tags:

reactjs

antd

I'm using antd table for data viewing and used separate antd pagination .I want to set page size of the antd table how to achive it.I'm not using default table pagination in antd table

 <Pagination defaultCurrent={1} total={data.length} pageSize={2} onChange={this.setPaginationData}/>

 <Table
      rowKey={data._id}
      columns={this.columns1}
      rowSelection={this.rowSelection}
      expandedRowRender={(record, index, indent, expanded) =>
                        this.expanding(record, expanded)                         
                    }
      // pagination={{defaultCurrent:1, total:data.length, pageSize:2,position:'top'}}

      onExpand={this.onExpand}
      dataSource={data} />

please help...

like image 432
Karthi Avatar asked Sep 16 '19 13:09

Karthi


2 Answers

You can simply pass an Paginationobject:

<Table pagination={{ pageSize: 6}} />
like image 97
J.Wincewicz Avatar answered Oct 23 '22 04:10

J.Wincewicz


You want to set page size without setting the pagination, so your only option is to limit the data:

const PAGE_SIZE = 5;
<Table dataSource={data.slice(PAGE_SIZE)} />;

Refer to Array#slice

like image 41
Dennis Vash Avatar answered Oct 23 '22 05:10

Dennis Vash