Skip to content

Commit

Permalink
fix #1108
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenFang committed Apr 1, 2017
1 parent 87158e0 commit 136dec9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/BootstrapTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,7 @@ BootstrapTable.propTypes = {
Const.ROW_SELECT_MULTI
]),
customComponent: PropTypes.func,
bgColor: PropTypes.string,
bgColor: PropTypes.oneOfType([ PropTypes.string, PropTypes.func ]),
selected: PropTypes.array,
onSelect: PropTypes.func,
onSelectAll: PropTypes.func,
Expand Down
1 change: 1 addition & 0 deletions src/TableBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ class TableBody extends Component {
}
const result = [ <TableRow isSelected={ selected } key={ key } className={ trClassName }
index={ r }
row={ data }
selectRow={ isSelectRowDefined ? this.props.selectRow : undefined }
enableCellEdit={ cellEdit.mode !== Const.CELL_EDIT_NONE }
onRowClick={ this.handleRowClick }
Expand Down
16 changes: 12 additions & 4 deletions src/TableRow.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint no-nested-ternary: 0 */
import classSet from 'classnames';
import React, { Component, PropTypes } from 'react';

Expand Down Expand Up @@ -71,12 +72,18 @@ class TableRow extends Component {

render() {
this.clickNum = 0;
const { selectRow, row, isSelected } = this.props;
let backgroundColor = null;

if (selectRow) {
backgroundColor = typeof selectRow.bgColor === 'function' ?
selectRow.bgColor(row, isSelected) : ( isSelected ? selectRow.bgColor : null);
}

const trCss = {
style: {
backgroundColor: this.props.isSelected ? this.props.selectRow.bgColor : null
},
style: { backgroundColor },
className: classSet(
this.props.isSelected ? this.props.selectRow.className : null,
isSelected ? selectRow.className : null,
this.props.className
)
};
Expand All @@ -92,6 +99,7 @@ class TableRow extends Component {
}
TableRow.propTypes = {
index: PropTypes.number,
row: PropTypes.any,
isSelected: PropTypes.bool,
enableCellEdit: PropTypes.bool,
onRowClick: PropTypes.func,
Expand Down

0 comments on commit 136dec9

Please sign in to comment.