简体   繁体   English

如何在使用antd表的同时检索我们当前所在的页码

[英]How to retrieve the page number we are currently on, while using an antd table

I have created a table with the Antd in Reactjs.我在 Reactjs 中使用 Antd 创建了一个表。 I have used 50 rows per page and I have around 6 pages that come up in the pagination.我每页使用了 50 行,分页中出现了大约 6 页。 I have added an index column to the table, which loops from 1 to 50 on every page.我在表中添加了一个索引列,它在每一页上从 1 到 50 循环。 Rather I need it to loop from 1 to full length.相反,我需要它从 1 循环到全长。 So when I navigate to page 2, It must show 51 to 100, whereas in my case it loops from 1 to 50 again.因此,当我导航到第 2 页时,它必须显示 51 到 100,而在我的情况下,它再次从 1 循环到 50。 I made use of "index",that is passed from the "render" function in the table.我使用了从表中的“渲染”函数传递的“索引”。

function indexRenderer(text, record, index) {
    return index+1
}

Is there any seperate function I can use to retrieve the page count alone from the pagination of antd.是否有任何单独的函数可以用来从 antd 的分页中单独检索页数。

You can use onChange function of Pagination component.您可以使用 Pagination 组件的onChange函数。

It will be called with page parameter.它将使用page参数调用。

Check this out for more information:查看此了解更多信息:

https://ant.design/components/pagination/ https://ant.design/components/pagination/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM