This commit is contained in:
Parth Prajapati
2018-01-31 07:43:05 +05:30
parent 09fadeb02b
commit feedcb9f4b
2 changed files with 16 additions and 4 deletions

View File

@@ -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}\`);
}
};

View File

@@ -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 (