Reputation: 21520
I'm trying to apply a background color on selected rows:
getTrProps={(state, rowInfo, column, instance) => ...}
on rowInfo
I can't find any information like "selected" or similar (also using selectTableHOC
)
Upvotes: 0
Views: 406
Reputation: 535
selected row column
getTrProps={(state, rowInfo, column) => {
return {
onClick: (e) => {
var a = this.state.selected.indexOf(rowInfo.index);
if (a == -1) {
// this.setState({selected: array.concat(this.state.selected, [rowInfo.index])});
this.setState({selected: [...this.state.selected, rowInfo.index]});
// Pass props to the React component
}
var array = this.state.selected;
if(a != -1){
array.splice(a, 1);
this.setState({selected: array});
}
},
// #393740 - Lighter, selected row
// #302f36 - Darker, not selected row
style: {background: this.state.selected.indexOf(rowInfo.index) != -1 ? '#393740': '#302f36'},
}
}}
Upvotes: 1