mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2026-06-28 21:20:04 +00:00
Solves #179
This commit is contained in:
@@ -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}\`);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
12
packages/react-bootstrap-table2/src/row.js
vendored
12
packages/react-bootstrap-table2/src/row.js
vendored
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user