From 1aaf605257679b91ef871e136af0c9061c9f22ef Mon Sep 17 00:00:00 2001 From: AllenFang Date: Tue, 31 Jan 2017 18:04:50 +0800 Subject: [PATCH] fix click on selection column can not trigger selection if clickToSelect enable --- src/TableBody.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/TableBody.js b/src/TableBody.js index 092860fc0..875fedfd0 100644 --- a/src/TableBody.js +++ b/src/TableBody.js @@ -116,7 +116,7 @@ class TableBody extends Component { const disable = unselectable.indexOf(key) !== -1; const selected = this.props.selectedRowKeys.indexOf(key) !== -1; const selectRowColumn = isSelectRowDefined && !this.props.selectRow.hideSelectColumn ? - this.renderSelectRowColumn(selected, inputType, disable, CustomComponent, r) : null; + this.renderSelectRowColumn(selected, inputType, disable, CustomComponent, r, data) : null; // add by bluespring for className customize let trClassName = this.props.trClassName; if (isFun(this.props.trClassName)) { @@ -276,9 +276,21 @@ class TableBody extends Component { } } - renderSelectRowColumn(selected, inputType, disabled, CustomComponent = null, rowIndex = null) { + handleClickonSelectColumn = (e, isSelect, rowIndex, row) => { + e.stopPropagation(); + if (e.target.tagName === 'TD' && this.props.selectRow.clickToSelect) { + const unselectable = this.props.selectRow.unselectable || []; + if (unselectable.indexOf(row[this.props.keyField]) === -1) { + this.handleSelectRow(rowIndex + 1, isSelect, e); + } + } + } + + renderSelectRowColumn(selected, inputType, disabled, CustomComponent = null, rowIndex = null, row) { return ( - e.stopPropagation() } style={ { textAlign: 'center' } }> + { + this.handleClickonSelectColumn(e, !selected, rowIndex, row); + } } style={ { textAlign: 'center' } }> { CustomComponent ?