Skip to content

Commit 8954de6

Browse files
committed
fix #1428
1 parent 5823e2a commit 8954de6

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

src/BootstrapTable.js

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class BootstrapTable extends Component {
1818
constructor(props) {
1919
super(props);
2020
this.isIE = false;
21-
this._attachCellEditFunc();
2221
if (Util.canUseDOM()) {
2322
this.isIE = document.documentMode;
2423
}
@@ -326,22 +325,11 @@ class BootstrapTable extends Component {
326325

327326
componentDidUpdate() {
328327
this._adjustTable();
329-
this._attachCellEditFunc();
330328
if (this.props.options.afterTableComplete) {
331329
this.props.options.afterTableComplete();
332330
}
333331
}
334332

335-
_attachCellEditFunc() {
336-
const { cellEdit } = this.props;
337-
if (cellEdit) {
338-
this.props.cellEdit.__onCompleteEdit__ = this.handleEditCell.bind(this);
339-
if (cellEdit.mode !== Const.CELL_EDIT_NONE) {
340-
this.props.selectRow.clickToSelect = false;
341-
}
342-
}
343-
}
344-
345333
/**
346334
* Returns true if in the current configuration,
347335
* the datagrid should load its data remotely.
@@ -394,6 +382,10 @@ class BootstrapTable extends Component {
394382
const { paginationPosition = Const.PAGINATION_POS_BOTTOM } = this.props.options;
395383
const showPaginationOnTop = paginationPosition !== Const.PAGINATION_POS_BOTTOM;
396384
const showPaginationOnBottom = paginationPosition !== Const.PAGINATION_POS_TOP;
385+
const selectRow = { ...this.props.selectRow };
386+
if (this.props.cellEdit && this.props.cellEdit.mode !== Const.CELL_EDIT_NONE) {
387+
selectRow.clickToSelect = false;
388+
}
397389

398390
return (
399391
<div className={ classSet('react-bs-table-container', this.props.className, this.props.containerClass) }
@@ -447,7 +439,7 @@ class BootstrapTable extends Component {
447439
hover={ this.props.hover }
448440
keyField={ this.store.getKeyField() }
449441
condensed={ this.props.condensed }
450-
selectRow={ this.props.selectRow }
442+
selectRow={ selectRow }
451443
expandColumnOptions={ this.props.expandColumnOptions }
452444
cellEdit={ this.props.cellEdit }
453445
selectedRowKeys={ this.state.selectedRowKeys }
@@ -466,7 +458,8 @@ class BootstrapTable extends Component {
466458
onNavigateCell={ this.handleNavigateCell }
467459
x={ this.state.x }
468460
y={ this.state.y }
469-
withoutTabIndex={ this.props.withoutTabIndex } />
461+
withoutTabIndex={ this.props.withoutTabIndex }
462+
onEditCell={ this.handleEditCell } />
470463
</div>
471464
{ tableFilter }
472465
{ showPaginationOnBottom ? pagination : null }
@@ -793,7 +786,7 @@ class BootstrapTable extends Component {
793786
}
794787
}
795788

796-
handleEditCell(newVal, rowIndex, colIndex) {
789+
handleEditCell = (newVal, rowIndex, colIndex) => {
797790
const { beforeSaveCell } = this.props.cellEdit;
798791
const columns = this.getColumnsDescription(this.props);
799792
const fieldName = columns[colIndex].name;

src/TableBody.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ class TableBody extends Component {
423423

424424
handleCompleteEditCell = (newVal, rowIndex, columnIndex) => {
425425
if (newVal !== null) {
426-
const result = this.props.cellEdit.__onCompleteEdit__(newVal, rowIndex, columnIndex);
426+
const result = this.props.onEditCell(newVal, rowIndex, columnIndex);
427427
if (result !== Const.AWAIT_BEFORE_CELL_EDIT) {
428428
this.setState(() => { return { currEditCell: null }; });
429429
}

0 commit comments

Comments
 (0)