mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2025-10-16 11:55:39 +00:00
* redefine cell callback function * it takes 4 argus `content`, `row`, `rowIndex` and `columnIndex` in * sequence. * [test] fix unit test for new callback * correct the version of story for new cell callback * [DOC] re-define structure of Contents of Table * [DOC] update document for attrs * re-write description for each column props * [DOC] update document for headerCell * re-write and add extra description for each header column props
52 lines
1.1 KiB
JavaScript
52 lines
1.1 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',
|
|
classes: 'demo-key-row'
|
|
}, {
|
|
dataField: 'name',
|
|
text: 'Product Name',
|
|
classes: (cell, row, rowIndex, colIndex) => {
|
|
if (rowIndex % 2 === 0) return 'demo-row-even';
|
|
return 'demo-row-odd';
|
|
}
|
|
}, {
|
|
dataField: 'price',
|
|
text: 'Product Price'
|
|
}];
|
|
|
|
const sourceCode = `\
|
|
const columns = [{
|
|
dataField: 'id',
|
|
text: 'Product ID',
|
|
classes: 'demo-key-row'
|
|
}, {
|
|
dataField: 'name',
|
|
text: 'Product Name',
|
|
classes: (cell, row, rowIndex, colIndex) => {
|
|
if (rowIndex % 2 === 0) return 'demo-row-even';
|
|
return 'demo-row-odd';
|
|
}
|
|
}, {
|
|
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>
|
|
);
|