Created
December 26, 2016 15:08
-
-
Save darklilium/3c9bbd08e2629dd75d7887b427b75517 to your computer and use it in GitHub Desktop.
[Griddle]Put color on row click.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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