gpt4 book ai didi

reactjs - 从 React Bootstrap 表中禁用/删除分页号

转载 作者:行者123 更新时间:2023-12-04 10:50:33 24 4
gpt4 key购买 nike

我想从分页中删除所有数字(1,2,...,n)。我只想显示 上、第一、下 最后 纽扣。

这是使用 react-bootstrap-table 创建的 Table 组件。

代码沙箱的附加工作示例。

codesandbox

表组件:

import React from "react";
import { BootstrapTable, TableHeaderColumn } from "react-bootstrap-table";
import { products } from "./products";

function Table() {
const renderShowsTotal = (start, to, total) => {
return (
<p style={{ color: "blue" }}>
From {start} to {to}, totals is {total}&nbsp;&nbsp;(its a
customize text)
</p>
);
};
const options = {
sizePerPageList: [
{
text: "5",
value: 5
},
{
text: "10",
value: 10
},
{
text: "All",
value: products.length
}
],
sizePerPage: 10, // which size per page you want to locate as default
// pageStartIndex: 0, // where to start counting the pages
// paginationSize: 3, // the pagination bar size.
prePage: "Prev", // Previous page button text
nextPage: "Next", // Next page button text
firstPage: "First", // First page button text
lastPage: "Last", // Last page button text
paginationShowsTotal: renderShowsTotal(), // Accept bool or function
paginationPosition: "bottom", // default is bottom, top and both is all available
hideSizePerPage: true, // You can hide the dropdown for sizePerPage
alwaysShowAllBtns: true // Always show next and previous button
// withFirstAndLast: false // Hide the going to First and Last page button
};
return (
<div className="react-bootstrap-table container mt-4">
<h2>React Bootstrap Table with pagination</h2>
<BootstrapTable data={products} pagination options={options}>
<TableHeaderColumn dataField="id" isKey={true}>
Product ID
</TableHeaderColumn>
<TableHeaderColumn dataField="name">
Product Name
</TableHeaderColumn>
<TableHeaderColumn dataField="price">
Product Price
</TableHeaderColumn>
</BootstrapTable>
</div>
);
}

export default Table;

提前致谢。

最佳答案

你可以在这里应用这个技巧。

添加 paginationSize你的选择

const options = {
...
paginationSize : 1,
...
}

然后申请 CSS ,
.page-item.active {
display: none;
}

Demo

关于reactjs - 从 React Bootstrap 表中禁用/删除分页号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59495648/

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