Example to demonstate how to customize sticky table

This commit is contained in:
Chun-MingChen 2018-11-03 18:36:21 +08:00
parent 6ff2ba35b4
commit f49c41cab1
4 changed files with 66 additions and 1 deletions

View File

@ -0,0 +1,55 @@
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(87);
const columns = [{
dataField: 'id',
text: 'Product ID'
}, {
dataField: 'name',
text: 'Product Name'
}, {
dataField: 'price',
text: 'Product Price'
}];
const style = `\
// Customizing your own sticky table style by simply overwriting .table-sticky
.react-bootstrap-table {
.sticky.table-sticky {
tbody {
max-height: 200px;
}
}
}
`;
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 sticky classes="sticky" keyField="id" data={ products } columns={ columns } />
`;
export default () => (
<div>
<BootstrapTable sticky classes="sticky" keyField="id" data={ products } columns={ columns } />
<Code>{ style }</Code>
<Code>{ sourceCode }</Code>
</div>
);

View File

@ -170,6 +170,7 @@ import TableOverlay from 'examples/loading-overlay/table-overlay';
// sticky header table
import StickyHeaderTable from 'examples/sticky-header/default';
import StickyHeaderCustomStyleTable from 'examples/sticky-header/customized-style.js';
// remote
import RemoteSort from 'examples/remote/remote-sort';
@ -367,7 +368,8 @@ storiesOf('Export CSV', module)
storiesOf('Sticky header', module)
.addDecorator(bootstrapStyle())
.add('Default sticky header', () => <StickyHeaderTable />);
.add('Default sticky header', () => <StickyHeaderTable />)
.add('Custom style for sticky header', () => <StickyHeaderCustomStyleTable />);
storiesOf('EmptyTableOverlay', module)
.addDecorator(bootstrapStyle())

View File

@ -0,0 +1,7 @@
.react-bootstrap-table {
.sticky.table-sticky {
tbody {
max-height: 200px;
}
}
}

View File

@ -12,3 +12,4 @@
@import "sort/index";
@import "search/index";
@import "loading-overlay/index";
@import "sticky/index";