Skip to content

Instantly share code, notes, and snippets.

@darklilium
Created December 26, 2016 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darklilium/3c9bbd08e2629dd75d7887b427b75517 to your computer and use it in GitHub Desktop.
Save darklilium/3c9bbd08e2629dd75d7887b427b75517 to your computer and use it in GitHub Desktop.
[Griddle]Put color on row click.
Source: http://stackoverflow.com/questions/39426819/selecting-a-row-in-react-griddle-and-changing-tr-background-color
First:
class ComponentWithGriddle extends React.Component {
constructor(props) {
super(props);
this.state = {
selectedRowId: 0,
};
}
onRowClick(row) {
this.setState({ selectedRowId: row.props.data.id });
}
render() {
const rowMetadata = {
bodyCssClassName: rowData => (rowData.id === this.state.selectedRowId ? 'selected' : ''),
};
return (
<Griddle
...
rowMetadata={rowMetadata}
onRowClick={this.onRowClick.bind(this)}
/>
);
}
}
Second: make a .selected td class and add the color what u want.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment