Skip to content

Commit feedcb9

Browse files
1 parent 09fadeb commit feedcb9

File tree

2 files changed

+16
-4
lines changed
  • packages

2 files changed

+16
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ const columns = [{
2020
}];
2121

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

@@ -40,8 +40,8 @@ const columns = [{
4040
}];
4141
4242
const rowEvents = {
43-
onClick: (e) => {
44-
alert('click on row');
43+
onClick: (e, rowIndex) => {
44+
alert(\`clicked on row with index: \${rowIndex}\`);
4545
}
4646
};
4747

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class Row extends Component {
1212
super(props);
1313
this.clickNum = 0;
1414
this.handleRowClick = this.handleRowClick.bind(this);
15+
this.handleSimpleRowClick = this.handleSimpleRowClick.bind(this);
1516
}
1617

1718
handleRowClick(e) {
@@ -56,6 +57,15 @@ class Row extends Component {
5657
}
5758
}
5859

60+
handleSimpleRowClick(e) {
61+
const {
62+
rowIndex,
63+
attrs
64+
} = this.props;
65+
66+
attrs.onClick(e, rowIndex);
67+
}
68+
5969
render() {
6070
const {
6171
row,
@@ -89,6 +99,8 @@ class Row extends Component {
8999
const trAttrs = { ...attrs };
90100
if (clickToSelect) {
91101
trAttrs.onClick = this.handleRowClick;
102+
} else {
103+
trAttrs.onClick = this.handleSimpleRowClick;
92104
}
93105

94106
return (

0 commit comments

Comments
 (0)