mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2025-10-16 11:55:39 +00:00
53 lines
1.3 KiB
JavaScript
53 lines
1.3 KiB
JavaScript
import React from 'react';
|
|
|
|
import BootstrapTable from 'react-bootstrap-table-next';
|
|
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 = `\
|
|
import BootstrapTable from 'react-bootstrap-table-next';
|
|
|
|
const columns = [{
|
|
dataField: 'id',
|
|
text: 'Product ID'
|
|
}, {
|
|
dataField: 'name',
|
|
text: 'Product Name'
|
|
}, {
|
|
dataField: 'price',
|
|
text: 'Product Price'
|
|
}];
|
|
|
|
<BootstrapTable id="bar" keyField='id' data={ products } columns={ columns } />
|
|
<BootstrapTable classes="foo" keyField='id' data={ products } columns={ columns } />
|
|
<BootstrapTable wrapperClasses="boo" keyField="id" data={ products } columns={ columns } />
|
|
`;
|
|
|
|
export default () => (
|
|
<div>
|
|
<h4> Customized table ID </h4>
|
|
<BootstrapTable id="bar" keyField="id" data={ products } columns={ columns } />
|
|
|
|
<h4> Customized table className </h4>
|
|
<BootstrapTable classes="foo" keyField="id" data={ products } columns={ columns } />
|
|
|
|
<h4> Customized wrapper className </h4>
|
|
<BootstrapTable wrapperClasses="boo" keyField="id" data={ products } columns={ columns } />
|
|
|
|
<Code>{ sourceCode }</Code>
|
|
</div>
|
|
);
|