Skip to content

Instantly share code, notes, and snippets.

@AllenFang
Created April 29, 2017 12:30
Show Gist options
  • Save AllenFang/865a791dd874c57a1766f4bee97d11aa to your computer and use it in GitHub Desktop.
Save AllenFang/865a791dd874c57a1766f4bee97d11aa to your computer and use it in GitHub Desktop.
class SelectBgColorDynamicTable extends React.Component {
render() {
const selectRowProp = {
mode: 'checkbox',
bgColor: function(row, isSelect) {
if (isSelect) {
const { id } = row;
if (id < 2) return 'blue';
else if (id < 4) return 'red';
else return 'yellow';
}
return null;
}
};
return (
<BootstrapTable data={ products } selectRow={ selectRowProp }>
<TableHeaderColumn dataField='id' isKey={ true }>Product ID</TableHeaderColumn>
<TableHeaderColumn dataField='name'>Product Name</TableHeaderColumn>
<TableHeaderColumn dataField='price'>Product Price</TableHeaderColumn>
</BootstrapTable>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment