File tree 3 files changed +14
-5
lines changed
3 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -1270,7 +1270,7 @@ BootstrapTable.propTypes = {
1270
1270
Const . ROW_SELECT_MULTI
1271
1271
] ) ,
1272
1272
customComponent : PropTypes . func ,
1273
- bgColor : PropTypes . string ,
1273
+ bgColor : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . func ] ) ,
1274
1274
selected : PropTypes . array ,
1275
1275
onSelect : PropTypes . func ,
1276
1276
onSelectAll : PropTypes . func ,
Original file line number Diff line number Diff line change @@ -153,6 +153,7 @@ class TableBody extends Component {
153
153
}
154
154
const result = [ < TableRow isSelected = { selected } key = { key } className = { trClassName }
155
155
index = { r }
156
+ row = { data }
156
157
selectRow = { isSelectRowDefined ? this . props . selectRow : undefined }
157
158
enableCellEdit = { cellEdit . mode !== Const . CELL_EDIT_NONE }
158
159
onRowClick = { this . handleRowClick }
Original file line number Diff line number Diff line change
1
+ /* eslint no-nested-ternary: 0 */
1
2
import classSet from 'classnames' ;
2
3
import React , { Component , PropTypes } from 'react' ;
3
4
@@ -71,12 +72,18 @@ class TableRow extends Component {
71
72
72
73
render ( ) {
73
74
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
+
74
83
const trCss = {
75
- style : {
76
- backgroundColor : this . props . isSelected ? this . props . selectRow . bgColor : null
77
- } ,
84
+ style : { backgroundColor } ,
78
85
className : classSet (
79
- this . props . isSelected ? this . props . selectRow . className : null ,
86
+ isSelected ? selectRow . className : null ,
80
87
this . props . className
81
88
)
82
89
} ;
@@ -92,6 +99,7 @@ class TableRow extends Component {
92
99
}
93
100
TableRow . propTypes = {
94
101
index : PropTypes . number ,
102
+ row : PropTypes . any ,
95
103
isSelected : PropTypes . bool ,
96
104
enableCellEdit : PropTypes . bool ,
97
105
onRowClick : PropTypes . func ,
You can’t perform that action at this time.
0 commit comments