mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2025-10-16 11:55:39 +00:00
fix #1006
This commit is contained in:
parent
963b8d669b
commit
c12d3faba3
@ -191,6 +191,7 @@ BootstrapTable.propTypes = {
|
|||||||
Const.INDICATOR_POSITION_LEFT,
|
Const.INDICATOR_POSITION_LEFT,
|
||||||
Const.INDICATOR_POSITION_RIGHT
|
Const.INDICATOR_POSITION_RIGHT
|
||||||
]),
|
]),
|
||||||
|
className: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
||||||
parentClassName: PropTypes.oneOfType([PropTypes.string, PropTypes.func])
|
parentClassName: PropTypes.oneOfType([PropTypes.string, PropTypes.func])
|
||||||
}),
|
}),
|
||||||
rowStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
|
rowStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
|
import cs from 'classnames';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { CSSTransition } from 'react-transition-group';
|
import { CSSTransition } from 'react-transition-group';
|
||||||
|
|
||||||
const ExpandRow = ({ children, expanded, onClosed, ...rest }) => (
|
const ExpandRow = ({ children, expanded, onClosed, className, ...rest }) => (
|
||||||
<tr>
|
<tr>
|
||||||
<td className="reset-expansion-style" { ...rest }>
|
<td className={ cs('reset-expansion-style', className) } { ...rest }>
|
||||||
<CSSTransition
|
<CSSTransition
|
||||||
appear
|
appear
|
||||||
in={ expanded }
|
in={ expanded }
|
||||||
@ -25,13 +26,15 @@ const ExpandRow = ({ children, expanded, onClosed, ...rest }) => (
|
|||||||
ExpandRow.propTypes = {
|
ExpandRow.propTypes = {
|
||||||
children: PropTypes.node,
|
children: PropTypes.node,
|
||||||
expanded: PropTypes.bool,
|
expanded: PropTypes.bool,
|
||||||
onClosed: PropTypes.func
|
onClosed: PropTypes.func,
|
||||||
|
className: PropTypes.string
|
||||||
};
|
};
|
||||||
|
|
||||||
ExpandRow.defaultProps = {
|
ExpandRow.defaultProps = {
|
||||||
children: null,
|
children: null,
|
||||||
expanded: false,
|
expanded: false,
|
||||||
onClosed: null
|
onClosed: null,
|
||||||
|
className: ''
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ExpandRow;
|
export default ExpandRow;
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import ExpansionContext from '../contexts/row-expand-context';
|
|||||||
export default (Component) => {
|
export default (Component) => {
|
||||||
const renderWithExpansion = (props, expandRow) => {
|
const renderWithExpansion = (props, expandRow) => {
|
||||||
let parentClassName = '';
|
let parentClassName = '';
|
||||||
|
let className = '';
|
||||||
const key = props.value;
|
const key = props.value;
|
||||||
|
|
||||||
const expanded = _.contains(expandRow.expanded, key);
|
const expanded = _.contains(expandRow.expanded, key);
|
||||||
@ -17,6 +18,10 @@ export default (Component) => {
|
|||||||
parentClassName = _.isFunction(expandRow.parentClassName) ?
|
parentClassName = _.isFunction(expandRow.parentClassName) ?
|
||||||
expandRow.parentClassName(expanded, props.row, props.rowIndex) :
|
expandRow.parentClassName(expanded, props.row, props.rowIndex) :
|
||||||
(expandRow.parentClassName || '');
|
(expandRow.parentClassName || '');
|
||||||
|
|
||||||
|
className = _.isFunction(expandRow.className) ?
|
||||||
|
expandRow.className(expanded, props.row, props.rowIndex) :
|
||||||
|
(expandRow.className || '');
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@ -33,6 +38,7 @@ export default (Component) => {
|
|||||||
colSpan={ props.visibleColumnSize }
|
colSpan={ props.visibleColumnSize }
|
||||||
expanded={ expanded }
|
expanded={ expanded }
|
||||||
onClosed={ () => expandRow.onClosed(key) }
|
onClosed={ () => expandRow.onClosed(key) }
|
||||||
|
className={ className }
|
||||||
>
|
>
|
||||||
{ expandRow.renderer(props.row, props.rowIndex) }
|
{ expandRow.renderer(props.row, props.rowIndex) }
|
||||||
</ExpandRow> : null
|
</ExpandRow> : null
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user