Skip to content

Commit c4f14e2

Browse files
Added row object to onClick
- attach onClick only if defined
1 parent feedcb9 commit c4f14e2

File tree

2 files changed

+5
-4
lines changed
  • packages

2 files changed

+5
-4
lines changed

packages/react-bootstrap-table2-example/examples/rows/row-event.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const columns = [{
2020
}];
2121

2222
const rowEvents = {
23-
onClick: (e, rowIndex) => {
23+
onClick: (e, row, rowIndex) => {
2424
alert(`clicked on row with index: ${rowIndex}`);
2525
}
2626
};

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Row extends Component {
3636

3737
const clickFn = () => {
3838
if (attrs.onClick) {
39-
attrs.onClick(e);
39+
attrs.onClick(e, row, rowIndex);
4040
}
4141
if (selectable) {
4242
const key = _.get(row, keyField);
@@ -59,11 +59,12 @@ class Row extends Component {
5959

6060
handleSimpleRowClick(e) {
6161
const {
62+
row,
6263
rowIndex,
6364
attrs
6465
} = this.props;
6566

66-
attrs.onClick(e, rowIndex);
67+
attrs.onClick(e, row, rowIndex);
6768
}
6869

6970
render() {
@@ -99,7 +100,7 @@ class Row extends Component {
99100
const trAttrs = { ...attrs };
100101
if (clickToSelect) {
101102
trAttrs.onClick = this.handleRowClick;
102-
} else {
103+
} else if (attrs.onClick) {
103104
trAttrs.onClick = this.handleSimpleRowClick;
104105
}
105106

0 commit comments

Comments
 (0)