mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2025-10-16 11:55:39 +00:00
add story for #1006
This commit is contained in:
parent
c12d3faba3
commit
056957b0b5
106
packages/react-bootstrap-table2-example/examples/row-expand/expanding-row-classname.js
vendored
Normal file
106
packages/react-bootstrap-table2-example/examples/row-expand/expanding-row-classname.js
vendored
Normal file
@ -0,0 +1,106 @@
|
||||
import React from 'react';
|
||||
|
||||
import BootstrapTable from 'react-bootstrap-table-next';
|
||||
import Code from 'components/common/code-block';
|
||||
import { productsExpandRowsGenerator } from 'utils/common';
|
||||
|
||||
const products = productsExpandRowsGenerator();
|
||||
|
||||
const columns = [{
|
||||
dataField: 'id',
|
||||
text: 'Product ID'
|
||||
}, {
|
||||
dataField: 'name',
|
||||
text: 'Product Name'
|
||||
}, {
|
||||
dataField: 'price',
|
||||
text: 'Product Price'
|
||||
}];
|
||||
|
||||
const expandRow1 = {
|
||||
className: 'expanding-foo',
|
||||
renderer: row => (
|
||||
<div>
|
||||
<p>{ `This Expand row is belong to rowKey ${row.id}` }</p>
|
||||
<p>You can render anything here, also you can add additional data on every row object</p>
|
||||
<p>expandRow.renderer callback will pass the origin row object to you</p>
|
||||
</div>
|
||||
)
|
||||
};
|
||||
|
||||
const expandRow2 = {
|
||||
className: (isExpanded, row, rowIndex) => {
|
||||
if (rowIndex > 2) return 'expanding-foo';
|
||||
return 'expanding-bar';
|
||||
},
|
||||
renderer: row => (
|
||||
<div>
|
||||
<p>{ `This Expand row is belong to rowKey ${row.id}` }</p>
|
||||
<p>You can render anything here, also you can add additional data on every row object</p>
|
||||
<p>expandRow.renderer callback will pass the origin row object to you</p>
|
||||
</div>
|
||||
)
|
||||
};
|
||||
|
||||
|
||||
const sourceCode1 = `\
|
||||
import BootstrapTable from 'react-bootstrap-table-next';
|
||||
|
||||
const columns = // omit...
|
||||
|
||||
const expandRow = {
|
||||
className: 'expanding-foo',
|
||||
renderer: row => (
|
||||
<div>.....</div>
|
||||
)
|
||||
};
|
||||
|
||||
<BootstrapTable
|
||||
keyField='id'
|
||||
data={ products }
|
||||
columns={ columns }
|
||||
expandRow={ expandRow }
|
||||
/>
|
||||
`;
|
||||
|
||||
const sourceCode2 = `\
|
||||
import BootstrapTable from 'react-bootstrap-table-next';
|
||||
|
||||
const columns = // omit...
|
||||
|
||||
const expandRow = {
|
||||
className: (isExpanded, row, rowIndex) => {
|
||||
if (rowIndex > 2) return 'expanding-foo';
|
||||
return 'expanding-bar';
|
||||
},
|
||||
renderer: row => (
|
||||
<div>...</div>
|
||||
)
|
||||
};
|
||||
|
||||
<BootstrapTable
|
||||
keyField='id'
|
||||
data={ products }
|
||||
columns={ columns }
|
||||
expandRow={ expandRow }
|
||||
/>
|
||||
`;
|
||||
|
||||
export default () => (
|
||||
<div>
|
||||
<BootstrapTable
|
||||
keyField="id"
|
||||
data={ products }
|
||||
columns={ columns }
|
||||
expandRow={ expandRow1 }
|
||||
/>
|
||||
<Code>{ sourceCode1 }</Code>
|
||||
<BootstrapTable
|
||||
keyField="id"
|
||||
data={ products }
|
||||
columns={ columns }
|
||||
expandRow={ expandRow2 }
|
||||
/>
|
||||
<Code>{ sourceCode2 }</Code>
|
||||
</div>
|
||||
);
|
||||
@ -167,6 +167,7 @@ import CustomExpandColumn from 'examples/row-expand/custom-expand-column';
|
||||
import ExpandColumnPosition from 'examples/row-expand/expand-column-position';
|
||||
import ExpandHooks from 'examples/row-expand/expand-hooks';
|
||||
import ParentRowClassName from 'examples/row-expand/parent-row-classname';
|
||||
import ExpandingRowClassName from 'examples/row-expand/expanding-row-classname';
|
||||
|
||||
// pagination
|
||||
import PaginationTable from 'examples/pagination';
|
||||
@ -420,7 +421,8 @@ storiesOf('Row Expand', module)
|
||||
.add('Custom Expand Indicator', () => <CustomExpandColumn />)
|
||||
.add('Expand Column Position', () => <ExpandColumnPosition />)
|
||||
.add('Expand Hooks', () => <ExpandHooks />)
|
||||
.add('Custom Parent Row ClassName', () => <ParentRowClassName />);
|
||||
.add('Custom Parent Row ClassName', () => <ParentRowClassName />)
|
||||
.add('Custom Expanding Row ClassName', () => <ExpandingRowClassName />);
|
||||
|
||||
storiesOf('Pagination', module)
|
||||
.addDecorator(bootstrapStyle())
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
.parent-expand-foo {
|
||||
.expanding-foo, .parent-expand-foo {
|
||||
background-color: coral;
|
||||
}
|
||||
|
||||
.parent-expand-bar {
|
||||
.expanding-bar, .parent-expand-bar {
|
||||
background-color: aqua;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user