Skip to content

Commit defcd04

Browse files
committed
Update bootstrap-table and row-consumer
Add new props to the bootstrap-table, nonSelectableStyle and nonSelectableClasses Update row-consume in order to support custom styles and classes for non selectable rows
1 parent 18caf0a commit defcd04

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

packages/react-bootstrap-table2/src/bootstrap-table.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ BootstrapTable.propTypes = {
166166
style: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
167167
classes: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
168168
nonSelectable: PropTypes.array,
169+
nonSelectableStyle: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
170+
nonSelectableClasses: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
169171
bgColor: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
170172
hideSelectColumn: PropTypes.bool,
171173
selectionRenderer: PropTypes.func,

packages/react-bootstrap-table2/src/row-selection/row-consumer.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export default (Component) => {
99
const key = props.value;
1010
const selected = _.contains(selectRow.selected, key);
1111
const selectable = !selectRow.nonSelectable || !_.contains(selectRow.nonSelectable, key);
12+
const notSelectable = _.contains(selectRow.nonSelectable, key);
1213

1314
let {
1415
style,
@@ -38,6 +39,22 @@ export default (Component) => {
3839
}
3940
}
4041

42+
if (notSelectable) {
43+
const notSelectableStyle = _.isFunction(selectRow.nonSelectableStyle)
44+
? selectRow.nonSelectableStyle(props.row, props.rowIndex)
45+
: selectRow.nonSelectableStyle;
46+
47+
const notSelectableClasses = _.isFunction(selectRow.nonSelectableClasses)
48+
? selectRow.nonSelectableClasses(props.row, props.rowIndex)
49+
: selectRow.nonSelectableClasses;
50+
51+
style = {
52+
...style,
53+
...notSelectableStyle
54+
};
55+
className = cs(className, notSelectableClasses) || undefined;
56+
}
57+
4158
return (
4259
<Component
4360
{ ...props }

0 commit comments

Comments
 (0)