Skip to content

Instantly share code, notes, and snippets.

@AllenFang
Created October 28, 2016 15:54
Show Gist options
  • Select an option

  • Save AllenFang/e5010f51cbbc22fc0f2fe4f181421e24 to your computer and use it in GitHub Desktop.

Select an option

Save AllenFang/e5010f51cbbc22fc0f2fe4f181421e24 to your computer and use it in GitHub Desktop.
const qualityType = {
0: 'good',
1: 'bad',
2: 'unknown'
};
function enumFormatter(cell, row, enumObject) {
return enumObject[cell];
}
class ProgrammaticallySelectFilter extends React.Component {
handleBtnClick = () => {
this.refs.nameCol.applyFilter(1);
}
render() {
return (
<div>
<button onClick={ this.handleBtnClick } className='btn btn-default'>Click to apply select filter</button>
<BootstrapTable data={ products }>
<TableHeaderColumn dataField='id' isKey>Product ID</TableHeaderColumn>
<TableHeaderColumn dataField='name'>Product Name</TableHeaderColumn>
<TableHeaderColumn ref='nameCol' dataField='quality' filterFormatted dataFormat={ enumFormatter }
formatExtraData={ qualityType } filter={ { type: 'SelectFilter', options: qualityType } }>Product Quality</TableHeaderColumn>
</BootstrapTable>
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment