mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2025-10-16 11:55:39 +00:00
48 lines
1.4 KiB
JavaScript
48 lines
1.4 KiB
JavaScript
import React from 'react';
|
|
|
|
import BootstrapTable from 'react-bootstrap-table2';
|
|
import Code from 'components/common/code-block';
|
|
import { productsGenerator } from 'utils/common';
|
|
|
|
const products = productsGenerator();
|
|
|
|
const columns = [{
|
|
dataField: 'id',
|
|
text: 'Product ID'
|
|
}, {
|
|
dataField: 'name',
|
|
text: 'Product Name'
|
|
}, {
|
|
dataField: 'price',
|
|
text: 'Product Price'
|
|
}];
|
|
|
|
const sourceCode = `\
|
|
const columns = [{
|
|
dataField: 'id',
|
|
text: 'Product ID'
|
|
}, {
|
|
dataField: 'name',
|
|
text: 'Product Name'
|
|
}, {
|
|
dataField: 'price',
|
|
text: 'Product Price'
|
|
}];
|
|
|
|
const CaptionElement = () => <h3 style={{ borderRadius: '0.25em', textAlign: 'center', color: 'purple', border: '1px solid purple', padding: '0.5em' }}>Component as Header</h3>;
|
|
|
|
<BootstrapTable keyField="id" data={ products } caption="Plain text header" columns={ columns } />
|
|
|
|
<BootstrapTable keyField="id" data={ products } caption={<CaptionElement />} columns={ columns } />
|
|
`;
|
|
|
|
const Caption = () => <h3 style={ { borderRadius: '0.25em', textAlign: 'center', color: 'purple', border: '1px solid purple', padding: '0.5em' } }>Component as Header</h3>;
|
|
|
|
export default () => (
|
|
<div>
|
|
<BootstrapTable keyField="id" data={ products } caption="Plain text header" columns={ columns } />
|
|
<BootstrapTable keyField="id" data={ products } caption={ <Caption /> } columns={ columns } />
|
|
<Code>{ sourceCode }</Code>
|
|
</div>
|
|
);
|