mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2025-10-16 11:55:39 +00:00
83 lines
1.9 KiB
JavaScript
83 lines
1.9 KiB
JavaScript
/* eslint react/prefer-stateless-function: 0 */
|
|
/* eslint no-console: 0 */
|
|
import React from 'react';
|
|
|
|
import BootstrapTable from 'react-bootstrap-table-next';
|
|
import paginationFactory 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 from 'react-bootstrap-table2-paginator';
|
|
|
|
const columns = [{
|
|
dataField: 'id',
|
|
text: 'Product ID'
|
|
}, {
|
|
dataField: 'name',
|
|
text: 'Product Name'
|
|
}, {
|
|
dataField: 'price',
|
|
text: 'Product Price'
|
|
}];
|
|
|
|
const options = {
|
|
onSizePerPageChange: (sizePerPage, page) => {
|
|
console.log('Size per page change!!!');
|
|
console.log('Newest size per page:' + sizePerPage);
|
|
console.log('Newest page:' + page);
|
|
},
|
|
onPageChange: (page, sizePerPage) => {
|
|
console.log('Page change!!!');
|
|
console.log('Newest size per page:' + sizePerPage);
|
|
console.log('Newest page:' + page);
|
|
}
|
|
};
|
|
|
|
<BootstrapTable
|
|
keyField="id"
|
|
data={ products }
|
|
columns={ columns }
|
|
pagination={ paginationFactory(options) }
|
|
/>
|
|
`;
|
|
|
|
const options = {
|
|
onSizePerPageChange: (sizePerPage, page) => {
|
|
console.log('Size per page change!!!');
|
|
console.log(`Newest size per page: ${sizePerPage}`);
|
|
console.log(`Newest page: ${page}`);
|
|
},
|
|
onPageChange: (page, sizePerPage) => {
|
|
console.log('Page change!!!');
|
|
console.log(`Newest size per page: ${sizePerPage}`);
|
|
console.log(`Newest page: ${page}`);
|
|
}
|
|
};
|
|
|
|
export default () => (
|
|
<div>
|
|
<BootstrapTable
|
|
keyField="id"
|
|
data={ products }
|
|
columns={ columns }
|
|
pagination={ paginationFactory(options) }
|
|
/>
|
|
<Code>{ sourceCode }</Code>
|
|
</div>
|
|
);
|