Skip to content

Commit 8bef7eb

Browse files
committed
1 parent 408a004 commit 8bef7eb

File tree

1 file changed

+30
-12
lines changed
  • packages/react-bootstrap-table2/src

1 file changed

+30
-12
lines changed

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

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,36 @@ import withRowExpansion from './row-expand/row-consumer';
1515
class Body extends React.Component {
1616
constructor(props) {
1717
super(props);
18-
if (props.cellEdit.createContext) {
19-
this.EditingCell = props.cellEdit.createEditingCell(_, props.cellEdit.options.onStartEdit);
18+
const {
19+
keyField,
20+
visibleColumnSize,
21+
cellEdit,
22+
selectRow,
23+
expandRow
24+
} = props;
25+
26+
// Construct Editing Cell Component
27+
if (cellEdit.createContext) {
28+
this.EditingCell = cellEdit.createEditingCell(_, cellEdit.options.onStartEdit);
2029
}
30+
31+
// Construct Row Component
32+
let RowComponent = SimpleRow;
33+
const selectRowEnabled = selectRow.mode !== Const.ROW_SELECT_DISABLED;
34+
const expandRowEnabled = !!expandRow.renderer;
35+
36+
if (expandRowEnabled) {
37+
RowComponent = withRowExpansion(RowAggregator, visibleColumnSize);
38+
}
39+
40+
if (selectRowEnabled) {
41+
RowComponent = withRowSelection(expandRowEnabled ? RowComponent : RowAggregator);
42+
}
43+
44+
if (cellEdit.createContext) {
45+
RowComponent = cellEdit.withRowLevelCellEdit(RowComponent, selectRowEnabled, keyField, _);
46+
}
47+
this.RowComponent = RowComponent;
2148
}
2249

2350
render() {
@@ -46,21 +73,12 @@ class Body extends React.Component {
4673
}
4774
content = <RowSection content={ indication } colSpan={ visibleColumnSize } />;
4875
} else {
49-
let RowComponent = SimpleRow;
5076
const selectRowEnabled = selectRow.mode !== Const.ROW_SELECT_DISABLED;
5177
const expandRowEnabled = !!expandRow.renderer;
5278

5379
const additionalRowProps = {};
54-
if (expandRowEnabled) {
55-
RowComponent = withRowExpansion(RowAggregator, visibleColumnSize);
56-
}
57-
58-
if (selectRowEnabled) {
59-
RowComponent = withRowSelection(expandRowEnabled ? RowComponent : RowAggregator);
60-
}
6180

6281
if (cellEdit.createContext) {
63-
RowComponent = cellEdit.withRowLevelCellEdit(RowComponent, selectRowEnabled, keyField, _);
6482
additionalRowProps.EditingCellComponent = this.EditingCell;
6583
}
6684

@@ -88,7 +106,7 @@ class Body extends React.Component {
88106
baseRowProps.style = _.isFunction(rowStyle) ? rowStyle(row, index) : rowStyle;
89107
baseRowProps.className = (_.isFunction(rowClasses) ? rowClasses(row, index) : rowClasses);
90108

91-
return <RowComponent { ...baseRowProps } />;
109+
return <this.RowComponent { ...baseRowProps } />;
92110
});
93111
}
94112

0 commit comments

Comments
 (0)