mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2025-10-16 11:55:39 +00:00
add story for PaginationTotalStandalone
This commit is contained in:
parent
2932b8a1b8
commit
f5f17897fd
107
packages/react-bootstrap-table2-example/examples/pagination/standalone-pagination-total.js
vendored
Normal file
107
packages/react-bootstrap-table2-example/examples/pagination/standalone-pagination-total.js
vendored
Normal file
@ -0,0 +1,107 @@
|
||||
/* eslint react/prefer-stateless-function: 0 */
|
||||
import React from 'react';
|
||||
|
||||
import BootstrapTable from 'react-bootstrap-table-next';
|
||||
import paginationFactory, { PaginationProvider, PaginationTotalStandalone, PaginationListStandalone } from 'react-bootstrap-table2-paginator';
|
||||
import Code from 'components/common/code-block';
|
||||
import { productsGenerator } from 'utils/common';
|
||||
|
||||
const products = productsGenerator(87);
|
||||
|
||||
const columns = [{
|
||||
dataField: 'id',
|
||||
text: 'Product ID'
|
||||
}, {
|
||||
dataField: 'name',
|
||||
text: 'Product Name'
|
||||
}, {
|
||||
dataField: 'price',
|
||||
text: 'Product Price'
|
||||
}];
|
||||
|
||||
const sourceCode = `\
|
||||
import BootstrapTable from 'react-bootstrap-table-next';
|
||||
import paginationFactory, { PaginationProvider, PaginationTotalStandalone, PaginationListStandalone } from 'react-bootstrap-table2-paginator';
|
||||
|
||||
const columns = [{
|
||||
dataField: 'id',
|
||||
text: 'Product ID'
|
||||
}, {
|
||||
dataField: 'name',
|
||||
text: 'Product Name'
|
||||
}, {
|
||||
dataField: 'price',
|
||||
text: 'Product Price'
|
||||
}];
|
||||
|
||||
const options = {
|
||||
custom: true,
|
||||
totalSize: products.length
|
||||
};
|
||||
|
||||
<PaginationProvider
|
||||
pagination={ paginationFactory(options) }
|
||||
>
|
||||
{
|
||||
({
|
||||
paginationProps,
|
||||
paginationTableProps
|
||||
}) => (
|
||||
<div>
|
||||
<PaginationTotalStandalone
|
||||
{ ...paginationProps }
|
||||
/>
|
||||
<PaginationListStandalone
|
||||
{ ...paginationProps }
|
||||
/>
|
||||
<BootstrapTable
|
||||
keyField="id"
|
||||
data={ products }
|
||||
columns={ columns }
|
||||
{ ...paginationTableProps }
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
</PaginationProvider>
|
||||
`;
|
||||
|
||||
const options = {
|
||||
custom: true,
|
||||
totalSize: products.length
|
||||
};
|
||||
|
||||
export default class StandalonePaginationList extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<PaginationProvider
|
||||
pagination={ paginationFactory(options) }
|
||||
>
|
||||
{
|
||||
({
|
||||
paginationProps,
|
||||
paginationTableProps
|
||||
}) => (
|
||||
<div>
|
||||
<PaginationTotalStandalone
|
||||
{ ...paginationProps }
|
||||
/>
|
||||
<PaginationListStandalone
|
||||
{ ...paginationProps }
|
||||
/>
|
||||
<BootstrapTable
|
||||
keyField="id"
|
||||
data={ products }
|
||||
columns={ columns }
|
||||
{ ...paginationTableProps }
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
</PaginationProvider>
|
||||
<Code>{ sourceCode }</Code>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -169,6 +169,7 @@ import CustomSizePerPageTable from 'examples/pagination/custom-size-per-page';
|
||||
import CustomPageListTable from 'examples/pagination/custom-page-list';
|
||||
import StandalonePaginationList from 'examples/pagination/standalone-pagination-list';
|
||||
import StandaloneSizePerPage from 'examples/pagination/standalone-size-per-page';
|
||||
import StandalonePaginationTotal from 'examples/pagination/standalone-pagination-total';
|
||||
import FullyCustomPaginationTable from 'examples/pagination/fully-custom-pagination';
|
||||
import RemoteStandalonePaginationTable from 'examples/pagination/remote-standalone-pagination';
|
||||
import CustomePaginationWithFilter from 'examples/pagination/custome-page-list-with-filter';
|
||||
@ -408,6 +409,7 @@ storiesOf('Pagination', module)
|
||||
.add('Custom SizePerPage', () => <CustomSizePerPageTable />)
|
||||
.add('Standalone Pagination List', () => <StandalonePaginationList />)
|
||||
.add('Standalone SizePerPage Dropdown', () => <StandaloneSizePerPage />)
|
||||
.add('Standalone Pagination Total', () => <StandalonePaginationTotal />)
|
||||
.add('Fully Custom Pagination', () => <FullyCustomPaginationTable />)
|
||||
.add('Remote Fully Custom Pagination', () => <RemoteStandalonePaginationTable />)
|
||||
.add('Custom Pagination with Filter', () => <CustomePaginationWithFilter />)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user