我正在尝试将每页更多的行从material table
. 到目前为止,我发现您可以添加一个数组,其中每页包含如意行。rowsPerPageOptions={[5, 10, 25, 50, 100]}
,但我的问题是当我应用 100 行时,表格会延伸到空白行。(我目前只从后端收到 24 行(文档))所以基本上它必须限于我拥有的数据。有人可以帮帮我吗?谢谢
divideItems = () => {
let startIndex = ((parseInt(this.state.activePaginationTab) + 1) * this.state.rowsPerPage) - this.state.rowsPerPage;
let endIndex = (parseInt(this.state.activePaginationTab) + 1) * this.state.rowsPerPage - 1;
let tabItems = [];
for (let i = startIndex; i <= endIndex; i++) {
if (this.state.items[i]) {
tabItems.push(this.state.items[i]);
}
}
this.setState({
tabItems
}, () => {
});
}
getNewIndex = (event, page) => {
this.setState({
activePaginationTab: page
}, () => { this.divideItems() })
// this.divideItems(page)
};
handleChangeRowsPerPage = (event) => {
this.setState({
rowsPerPage: event.target.value
}, () => {
this.divideItems();
})
}
render() {
components={{
Pagination: props => (
<TablePagination
{...props}
rowsPerPageOptions={[5, 10, 25, 50,100]}
rowsPerPage={this.state.rowsPerPage}
count={this.state.items.length}
/>
),