mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2025-10-16 11:55:39 +00:00
add story for #778
This commit is contained in:
parent
ecea3efdaa
commit
4506a3dea2
92
packages/react-bootstrap-table2-example/examples/pagination/custome-page-list-with-filter.js
vendored
Normal file
92
packages/react-bootstrap-table2-example/examples/pagination/custome-page-list-with-filter.js
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
/* eslint react/prefer-stateless-function: 0 */
|
||||
import React from 'react';
|
||||
|
||||
import BootstrapTable from 'react-bootstrap-table-next';
|
||||
import paginationFactory, { PaginationProvider, PaginationListStandalone } from 'react-bootstrap-table2-paginator';
|
||||
import cellEditFactory from 'react-bootstrap-table2-editor';
|
||||
import filterFactory, { textFilter } from 'react-bootstrap-table2-filter';
|
||||
import Code from 'components/common/code-block';
|
||||
import { productsGenerator } from 'utils/common';
|
||||
|
||||
const products = productsGenerator(21);
|
||||
|
||||
const columns = [{
|
||||
dataField: 'id',
|
||||
text: 'Product ID',
|
||||
filter: textFilter({})
|
||||
}, {
|
||||
dataField: 'name',
|
||||
text: 'Product Name',
|
||||
filter: textFilter()
|
||||
}];
|
||||
|
||||
const sourceCode = `\
|
||||
import BootstrapTable from 'react-bootstrap-table-next';
|
||||
import paginationFactory from 'react-bootstrap-table2-paginator';
|
||||
|
||||
const columns = [{
|
||||
dataField: 'id',
|
||||
text: 'Product ID',
|
||||
filter: textFilter({})
|
||||
}, {
|
||||
dataField: 'name',
|
||||
text: 'Product Name',
|
||||
filter: textFilter()
|
||||
}];
|
||||
|
||||
<BootstrapTable keyField='id' data={ products } columns={ columns } pagination={ paginationFactory() } />
|
||||
`;
|
||||
|
||||
export default class Table extends React.Component {
|
||||
render() {
|
||||
const options = {
|
||||
custom: true,
|
||||
paginationSize: 4,
|
||||
pageStartIndex: 1,
|
||||
firstPageText: 'First',
|
||||
prePageText: 'Back',
|
||||
nextPageText: 'Next',
|
||||
lastPageText: 'Last',
|
||||
nextPageTitle: 'First page',
|
||||
prePageTitle: 'Pre page',
|
||||
firstPageTitle: 'Next page',
|
||||
lastPageTitle: 'Last page',
|
||||
showTotal: true,
|
||||
totalSize: products.length
|
||||
};
|
||||
const contentTable = ({ paginationProps, paginationTableProps }) => (
|
||||
<div>
|
||||
<PaginationListStandalone { ...paginationProps } />
|
||||
<div>
|
||||
<div>
|
||||
<BootstrapTable
|
||||
striped
|
||||
hover
|
||||
keyField="id"
|
||||
data={ products }
|
||||
columns={ columns }
|
||||
filter={ filterFactory() }
|
||||
cellEdit={ cellEditFactory() }
|
||||
{ ...paginationTableProps }
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<PaginationListStandalone { ...paginationProps } />
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h2>PaginationProvider will care the data size change. You dont do anything</h2>
|
||||
<PaginationProvider
|
||||
pagination={
|
||||
paginationFactory(options)
|
||||
}
|
||||
>
|
||||
{ contentTable }
|
||||
</PaginationProvider>
|
||||
<Code>{ sourceCode }</Code>
|
||||
</div >
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -169,6 +169,7 @@ import StandalonePaginationList from 'examples/pagination/standalone-pagination-
|
||||
import StandaloneSizePerPage from 'examples/pagination/standalone-size-per-page';
|
||||
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';
|
||||
|
||||
// search
|
||||
import SearchTable from 'examples/search';
|
||||
@ -390,7 +391,8 @@ storiesOf('Pagination', module)
|
||||
.add('Standalone Pagination List', () => <StandalonePaginationList />)
|
||||
.add('Standalone SizePerPage Dropdown', () => <StandaloneSizePerPage />)
|
||||
.add('Fully Custom Pagination', () => <FullyCustomPaginationTable />)
|
||||
.add('Remote Fully Custom Pagination', () => <RemoteStandalonePaginationTable />);
|
||||
.add('Remote Fully Custom Pagination', () => <RemoteStandalonePaginationTable />)
|
||||
.add('Custom Pagination with Filter', () => <CustomePaginationWithFilter />);
|
||||
|
||||
storiesOf('Table Search', module)
|
||||
.addDecorator(bootstrapStyle())
|
||||
|
||||
Loading…
Reference in New Issue
Block a user