mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2025-10-16 11:55:39 +00:00
Example to demonstate how to customize sticky table
This commit is contained in:
parent
6ff2ba35b4
commit
f49c41cab1
55
packages/react-bootstrap-table2-example/examples/sticky-header/customized-style.js
vendored
Normal file
55
packages/react-bootstrap-table2-example/examples/sticky-header/customized-style.js
vendored
Normal 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>
|
||||
);
|
||||
@ -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())
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
.react-bootstrap-table {
|
||||
.sticky.table-sticky {
|
||||
tbody {
|
||||
max-height: 200px;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -12,3 +12,4 @@
|
||||
@import "sort/index";
|
||||
@import "search/index";
|
||||
@import "loading-overlay/index";
|
||||
@import "sticky/index";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user