gpt4 book ai didi

reactjs - Material UI TablePagination 句柄与 Redux/React

转载 作者:行者123 更新时间:2023-12-02 17:09:43 29 4
gpt4 key购买 nike

我正在尝试管理 MaterialUI 表格页面的状态。我目前正在使用 onChangePage 属性,但这使我只能通过“添加”页面进行导航,即只能在一个方向上导航,因此我无法返回到之前的页面。我的问题是如何根据您单击的按钮选择事件类型,因为如果您单击两个页面按钮中的任何一个,它只会前进到下一页。

这是表格分页部分:

<TablePagination
component="div"
count= {this.props.logs.length}
rowsPerPage={this.props.rowsPerPage}
page={this.props.page}
backIconButtonProps={{
'aria-label': 'Previous Page',
}}
nextIconButtonProps={{
'aria-label': 'Next Page',
}}
onChangePage={this.handleChangePage}
/>

我的 handleChangePage 看起来像这样:

handleChangePage = (event) => {
this.props.dispatch(nextPage(this.props.page))
}

那么,如何使用 MaterialUI Tables 的 onChangePage 功能区分前进或返回上一页?

最佳答案

嗨,这是我的解决方案:)

 <TablePagination
...
backIconButtonProps={{
'aria-label': 'Previous Page',
'onClick': this.loadPreviousPage,
}}
nextIconButtonProps={{
'aria-label': 'Next Page',
'onClick': this.loadNextPage,
}}
...
/>

关于reactjs - Material UI TablePagination 句柄与 Redux/React,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49861391/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com