diff --git a/packages/react-bootstrap-table2-example/examples/rows/row-event.js b/packages/react-bootstrap-table2-example/examples/rows/row-event.js index 915f9af..d65d99a 100644 --- a/packages/react-bootstrap-table2-example/examples/rows/row-event.js +++ b/packages/react-bootstrap-table2-example/examples/rows/row-event.js @@ -20,8 +20,8 @@ const columns = [{ }]; const rowEvents = { - onClick: (e) => { - alert('click on row'); + onClick: (e, rowIndex) => { + alert(`clicked on row with index: ${rowIndex}`); } }; @@ -40,8 +40,8 @@ const columns = [{ }]; const rowEvents = { - onClick: (e) => { - alert('click on row'); + onClick: (e, rowIndex) => { + alert(\`clicked on row with index: \${rowIndex}\`); } }; diff --git a/packages/react-bootstrap-table2/src/row.js b/packages/react-bootstrap-table2/src/row.js index 24f443a..6edaac9 100644 --- a/packages/react-bootstrap-table2/src/row.js +++ b/packages/react-bootstrap-table2/src/row.js @@ -12,6 +12,7 @@ class Row extends Component { super(props); this.clickNum = 0; this.handleRowClick = this.handleRowClick.bind(this); + this.handleSimpleRowClick = this.handleSimpleRowClick.bind(this); } handleRowClick(e) { @@ -56,6 +57,15 @@ class Row extends Component { } } + handleSimpleRowClick(e) { + const { + rowIndex, + attrs + } = this.props; + + attrs.onClick(e, rowIndex); + } + render() { const { row, @@ -89,6 +99,8 @@ class Row extends Component { const trAttrs = { ...attrs }; if (clickToSelect) { trAttrs.onClick = this.handleRowClick; + } else { + trAttrs.onClick = this.handleSimpleRowClick; } return (