react-bootstrap-table2/packages/react-bootstrap-table2-example/examples/header-columns/column-title-table.js
ChunMing, Chen f9ccbd0717 examples enhance
* utils for products generator

* load test for each *.test.js file in packages folder

* [test] unit test for utils/common

* refactor all products with productGenerator for all examples

* refactor folder structure

* move component <Code /> to src/components/common
* rename component file name
2017-09-04 08:46:01 -05:00

46 lines
1.0 KiB
JavaScript

/* eslint no-unused-vars: 0 */
import React from 'react';
import { BootstrapTableful } 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',
headerTitle: true
}, {
dataField: 'name',
text: 'Product Name',
headerTitle: (column, colIndex) => `this is custom title for ${column.text}`
}, {
dataField: 'price',
text: 'Product Price'
}];
const sourceCode = `\
const columns = [{
dataField: 'id',
text: 'Product ID',
headerTitle: true
}, {
dataField: 'name',
text: 'Product Name',
headerTitle: (column, colIndex) => \`this is custom title for \${column.text}\`
}, {
dataField: 'price',
text: 'Product Price'
}];
<BootstrapTableful keyField='id' data={ products } columns={ columns } />
`;
export default () => (
<div>
<BootstrapTableful keyField="id" data={ products } columns={ columns } />
<Code>{ sourceCode }</Code>
</div>
);