File tree Expand file tree Collapse file tree 3 files changed +14
-5
lines changed
Expand file tree Collapse file tree 3 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -1270,7 +1270,7 @@ BootstrapTable.propTypes = {
12701270 Const . ROW_SELECT_MULTI
12711271 ] ) ,
12721272 customComponent : PropTypes . func ,
1273- bgColor : PropTypes . string ,
1273+ bgColor : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . func ] ) ,
12741274 selected : PropTypes . array ,
12751275 onSelect : PropTypes . func ,
12761276 onSelectAll : PropTypes . func ,
Original file line number Diff line number Diff line change @@ -153,6 +153,7 @@ class TableBody extends Component {
153153 }
154154 const result = [ < TableRow isSelected = { selected } key = { key } className = { trClassName }
155155 index = { r }
156+ row = { data }
156157 selectRow = { isSelectRowDefined ? this . props . selectRow : undefined }
157158 enableCellEdit = { cellEdit . mode !== Const . CELL_EDIT_NONE }
158159 onRowClick = { this . handleRowClick }
Original file line number Diff line number Diff line change 1+ /* eslint no-nested-ternary: 0 */
12import classSet from 'classnames' ;
23import React , { Component , PropTypes } from 'react' ;
34
@@ -71,12 +72,18 @@ class TableRow extends Component {
7172
7273 render ( ) {
7374 this . clickNum = 0 ;
75+ const { selectRow, row, isSelected } = this . props ;
76+ let backgroundColor = null ;
77+
78+ if ( selectRow ) {
79+ backgroundColor = typeof selectRow . bgColor === 'function' ?
80+ selectRow . bgColor ( row , isSelected ) : ( isSelected ? selectRow . bgColor : null ) ;
81+ }
82+
7483 const trCss = {
75- style : {
76- backgroundColor : this . props . isSelected ? this . props . selectRow . bgColor : null
77- } ,
84+ style : { backgroundColor } ,
7885 className : classSet (
79- this . props . isSelected ? this . props . selectRow . className : null ,
86+ isSelected ? selectRow . className : null ,
8087 this . props . className
8188 )
8289 } ;
@@ -92,6 +99,7 @@ class TableRow extends Component {
9299}
93100TableRow . propTypes = {
94101 index : PropTypes . number ,
102+ row : PropTypes . any ,
95103 isSelected : PropTypes . bool ,
96104 enableCellEdit : PropTypes . bool ,
97105 onRowClick : PropTypes . func ,
You can’t perform that action at this time.
0 commit comments