Solves #179
This commit is contained in:
Allen
2018-02-04 21:37:10 +08:00
committed by GitHub
2 changed files with 18 additions and 5 deletions
@@ -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
View File
@@ -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 (