Skip to content

Commit

Permalink
fix #1428
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenFang committed Jul 16, 2017
1 parent 5823e2a commit 8954de6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
23 changes: 8 additions & 15 deletions src/BootstrapTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class BootstrapTable extends Component {
constructor(props) {
super(props);
this.isIE = false;
this._attachCellEditFunc();
if (Util.canUseDOM()) {
this.isIE = document.documentMode;
}
Expand Down Expand Up @@ -326,22 +325,11 @@ class BootstrapTable extends Component {

componentDidUpdate() {
this._adjustTable();
this._attachCellEditFunc();
if (this.props.options.afterTableComplete) {
this.props.options.afterTableComplete();
}
}

_attachCellEditFunc() {
const { cellEdit } = this.props;
if (cellEdit) {
this.props.cellEdit.__onCompleteEdit__ = this.handleEditCell.bind(this);
if (cellEdit.mode !== Const.CELL_EDIT_NONE) {
this.props.selectRow.clickToSelect = false;
}
}
}

/**
* Returns true if in the current configuration,
* the datagrid should load its data remotely.
Expand Down Expand Up @@ -394,6 +382,10 @@ class BootstrapTable extends Component {
const { paginationPosition = Const.PAGINATION_POS_BOTTOM } = this.props.options;
const showPaginationOnTop = paginationPosition !== Const.PAGINATION_POS_BOTTOM;
const showPaginationOnBottom = paginationPosition !== Const.PAGINATION_POS_TOP;
const selectRow = { ...this.props.selectRow };
if (this.props.cellEdit && this.props.cellEdit.mode !== Const.CELL_EDIT_NONE) {
selectRow.clickToSelect = false;
}

return (
<div className={ classSet('react-bs-table-container', this.props.className, this.props.containerClass) }
Expand Down Expand Up @@ -447,7 +439,7 @@ class BootstrapTable extends Component {
hover={ this.props.hover }
keyField={ this.store.getKeyField() }
condensed={ this.props.condensed }
selectRow={ this.props.selectRow }
selectRow={ selectRow }
expandColumnOptions={ this.props.expandColumnOptions }
cellEdit={ this.props.cellEdit }
selectedRowKeys={ this.state.selectedRowKeys }
Expand All @@ -466,7 +458,8 @@ class BootstrapTable extends Component {
onNavigateCell={ this.handleNavigateCell }
x={ this.state.x }
y={ this.state.y }
withoutTabIndex={ this.props.withoutTabIndex } />
withoutTabIndex={ this.props.withoutTabIndex }
onEditCell={ this.handleEditCell } />
</div>
{ tableFilter }
{ showPaginationOnBottom ? pagination : null }
Expand Down Expand Up @@ -793,7 +786,7 @@ class BootstrapTable extends Component {
}
}

handleEditCell(newVal, rowIndex, colIndex) {
handleEditCell = (newVal, rowIndex, colIndex) => {
const { beforeSaveCell } = this.props.cellEdit;
const columns = this.getColumnsDescription(this.props);
const fieldName = columns[colIndex].name;
Expand Down
2 changes: 1 addition & 1 deletion src/TableBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ class TableBody extends Component {

handleCompleteEditCell = (newVal, rowIndex, columnIndex) => {
if (newVal !== null) {
const result = this.props.cellEdit.__onCompleteEdit__(newVal, rowIndex, columnIndex);
const result = this.props.onEditCell(newVal, rowIndex, columnIndex);
if (result !== Const.AWAIT_BEFORE_CELL_EDIT) {
this.setState(() => { return { currEditCell: null }; });
}
Expand Down

0 comments on commit 8954de6

Please sign in to comment.