This commit is contained in:
AllenFang 2019-08-24 14:59:36 +08:00
parent 963b8d669b
commit c12d3faba3
3 changed files with 14 additions and 4 deletions

View File

@ -191,6 +191,7 @@ BootstrapTable.propTypes = {
Const.INDICATOR_POSITION_LEFT,
Const.INDICATOR_POSITION_RIGHT
]),
className: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
parentClassName: PropTypes.oneOfType([PropTypes.string, PropTypes.func])
}),
rowStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),

View File

@ -1,10 +1,11 @@
import cs from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';
import { CSSTransition } from 'react-transition-group';
const ExpandRow = ({ children, expanded, onClosed, ...rest }) => (
const ExpandRow = ({ children, expanded, onClosed, className, ...rest }) => (
<tr>
<td className="reset-expansion-style" { ...rest }>
<td className={ cs('reset-expansion-style', className) } { ...rest }>
<CSSTransition
appear
in={ expanded }
@ -25,13 +26,15 @@ const ExpandRow = ({ children, expanded, onClosed, ...rest }) => (
ExpandRow.propTypes = {
children: PropTypes.node,
expanded: PropTypes.bool,
onClosed: PropTypes.func
onClosed: PropTypes.func,
className: PropTypes.string
};
ExpandRow.defaultProps = {
children: null,
expanded: false,
onClosed: null
onClosed: null,
className: ''
};
export default ExpandRow;

View File

@ -8,6 +8,7 @@ import ExpansionContext from '../contexts/row-expand-context';
export default (Component) => {
const renderWithExpansion = (props, expandRow) => {
let parentClassName = '';
let className = '';
const key = props.value;
const expanded = _.contains(expandRow.expanded, key);
@ -17,6 +18,10 @@ export default (Component) => {
parentClassName = _.isFunction(expandRow.parentClassName) ?
expandRow.parentClassName(expanded, props.row, props.rowIndex) :
(expandRow.parentClassName || '');
className = _.isFunction(expandRow.className) ?
expandRow.className(expanded, props.row, props.rowIndex) :
(expandRow.className || '');
}
return [
@ -33,6 +38,7 @@ export default (Component) => {
colSpan={ props.visibleColumnSize }
expanded={ expanded }
onClosed={ () => expandRow.onClosed(key) }
className={ className }
>
{ expandRow.renderer(props.row, props.rowIndex) }
</ExpandRow> : null