mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2026-04-05 04:14:26 +00:00
[example] add demo for customized classes and id table
This commit is contained in:
48
packages/react-bootstrap-table2-example/examples/basic/customized-id-classes.js
vendored
Normal file
48
packages/react-bootstrap-table2-example/examples/basic/customized-id-classes.js
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
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();
|
||||
|
||||
const columns = [{
|
||||
dataField: 'id',
|
||||
text: 'Product ID'
|
||||
}, {
|
||||
dataField: 'name',
|
||||
text: 'Product Name'
|
||||
}, {
|
||||
dataField: 'price',
|
||||
text: 'Product Price'
|
||||
}];
|
||||
|
||||
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 id="bar" keyField='id' data={ products } columns={ columns } />
|
||||
<BootstrapTable classes="foo" keyField='id' data={ products } columns={ columns } />
|
||||
`;
|
||||
|
||||
export default () => (
|
||||
<div>
|
||||
<h4> Customized table ID </h4>
|
||||
<BootstrapTable id="bar" keyField="id" data={ products } columns={ columns } />
|
||||
|
||||
<h4> Customized table className </h4>
|
||||
<BootstrapTable classes="foo" keyField="id" data={ products } columns={ columns } />
|
||||
|
||||
<Code>{ sourceCode }</Code>
|
||||
</div>
|
||||
);
|
||||
@@ -9,6 +9,7 @@ import BasicTable from 'examples/basic';
|
||||
import BorderlessTable from 'examples/basic/borderless-table';
|
||||
import StripHoverCondensedTable from 'examples/basic/striped-hover-condensed-table';
|
||||
import NoDataTable from 'examples/basic/no-data-table';
|
||||
import CustomizedIdClassesTable from 'examples/basic/customized-id-classes';
|
||||
import CaptionTable from 'examples/basic/caption-table';
|
||||
|
||||
// work on columns
|
||||
@@ -121,6 +122,7 @@ storiesOf('Basic Table', module)
|
||||
.add('striped, hover, condensed table', () => <StripHoverCondensedTable />)
|
||||
.add('borderless table', () => <BorderlessTable />)
|
||||
.add('Indication For Empty Table', () => <NoDataTable />)
|
||||
.add('Customized id and class table', () => <CustomizedIdClassesTable />)
|
||||
.add('Table with caption', () => <CaptionTable />);
|
||||
|
||||
storiesOf('Work on Columns', module)
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
table.foo {
|
||||
background-color: $grey-500;
|
||||
}
|
||||
|
||||
table#bar {
|
||||
background-color: $light-blue;
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
@import "base/github-corner";
|
||||
@import "base/code-block";
|
||||
|
||||
@import "base-table/index";
|
||||
@import "welcome/index";
|
||||
@import "columns/index";
|
||||
@import "cell-edit/index";
|
||||
|
||||
Reference in New Issue
Block a user