Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8a8c2d4

Browse files
[example] add demo for customized classes and id table
1 parent 3cea965 commit 8a8c2d4

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import React from 'react';
2+
3+
import BootstrapTable from 'react-bootstrap-table-next';
4+
import Code from 'components/common/code-block';
5+
import { productsGenerator } from 'utils/common';
6+
7+
const products = productsGenerator();
8+
9+
const columns = [{
10+
dataField: 'id',
11+
text: 'Product ID'
12+
}, {
13+
dataField: 'name',
14+
text: 'Product Name'
15+
}, {
16+
dataField: 'price',
17+
text: 'Product Price'
18+
}];
19+
20+
const sourceCode = `\
21+
import BootstrapTable from 'react-bootstrap-table-next';
22+
23+
const columns = [{
24+
dataField: 'id',
25+
text: 'Product ID'
26+
}, {
27+
dataField: 'name',
28+
text: 'Product Name'
29+
}, {
30+
dataField: 'price',
31+
text: 'Product Price'
32+
}];
33+
34+
<BootstrapTable id="bar" keyField='id' data={ products } columns={ columns } />
35+
<BootstrapTable classes="foo" keyField='id' data={ products } columns={ columns } />
36+
`;
37+
38+
export default () => (
39+
<div>
40+
<h4> Customized table ID </h4>
41+
<BootstrapTable id="bar" keyField="id" data={ products } columns={ columns } />
42+
43+
<h4> Customized table className </h4>
44+
<BootstrapTable classes="foo" keyField="id" data={ products } columns={ columns } />
45+
46+
<Code>{ sourceCode }</Code>
47+
</div>
48+
);

‎packages/react-bootstrap-table2-example/stories/index.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import BasicTable from 'examples/basic';
99
import BorderlessTable from 'examples/basic/borderless-table';
1010
import StripHoverCondensedTable from 'examples/basic/striped-hover-condensed-table';
1111
import NoDataTable from 'examples/basic/no-data-table';
12+
import CustomizedIdClassesTable from 'examples/basic/customized-id-classes';
1213
import CaptionTable from 'examples/basic/caption-table';
1314

1415
// work on columns
@@ -121,6 +122,7 @@ storiesOf('Basic Table', module)
121122
.add('striped, hover, condensed table', () => <StripHoverCondensedTable />)
122123
.add('borderless table', () => <BorderlessTable />)
123124
.add('Indication For Empty Table', () => <NoDataTable />)
125+
.add('Customized id and class table', () => <CustomizedIdClassesTable />)
124126
.add('Table with caption', () => <CaptionTable />);
125127

126128
storiesOf('Work on Columns', module)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
table.foo {
2+
background-color: $grey-500;
3+
}
4+
5+
table#bar {
6+
background-color: $light-blue;
7+
}

‎packages/react-bootstrap-table2-example/stories/stylesheet/storybook.scss‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@import "base/github-corner";
44
@import "base/code-block";
55

6+
@import "base-table/index";
67
@import "welcome/index";
78
@import "columns/index";
89
@import "cell-edit/index";

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /