mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2026-08-11 19:50:17 +00:00
@@ -20,8 +20,8 @@ const columns = [{
|
||||
}];
|
||||
|
||||
const rowEvents = {
|
||||
onClick: (e) => {
|
||||
alert('click on row');
|
||||
onClick: (e, row, rowIndex) => {
|
||||
alert(`clicked on row with index: ${rowIndex}`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -40,8 +40,8 @@ const columns = [{
|
||||
}];
|
||||
|
||||
const rowEvents = {
|
||||
onClick: (e) => {
|
||||
alert('click on row');
|
||||
onClick: (e, row, rowIndex) => {
|
||||
alert(\`clicked on row with index: \${rowIndex}\`);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+14
-1
@@ -13,6 +13,7 @@ class Row extends Component {
|
||||
super(props);
|
||||
this.clickNum = 0;
|
||||
this.handleRowClick = this.handleRowClick.bind(this);
|
||||
this.handleSimpleRowClick = this.handleSimpleRowClick.bind(this);
|
||||
}
|
||||
|
||||
handleRowClick(e) {
|
||||
@@ -36,7 +37,7 @@ class Row extends Component {
|
||||
|
||||
const clickFn = () => {
|
||||
if (attrs.onClick) {
|
||||
attrs.onClick(e);
|
||||
attrs.onClick(e, row, rowIndex);
|
||||
}
|
||||
if (selectable) {
|
||||
const key = _.get(row, keyField);
|
||||
@@ -57,6 +58,16 @@ class Row extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
handleSimpleRowClick(e) {
|
||||
const {
|
||||
row,
|
||||
rowIndex,
|
||||
attrs
|
||||
} = this.props;
|
||||
|
||||
attrs.onClick(e, row, rowIndex);
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
row,
|
||||
@@ -90,6 +101,8 @@ class Row extends Component {
|
||||
const trAttrs = { ...attrs };
|
||||
if (clickToSelect) {
|
||||
trAttrs.onClick = this.handleRowClick;
|
||||
} else if (attrs.onClick) {
|
||||
trAttrs.onClick = this.handleSimpleRowClick;
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user