Skip to content

Instantly share code, notes, and snippets.

@AllenFang
Created November 14, 2016 15:51
Show Gist options
  • Select an option

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

Select an option

Save AllenFang/1c25909ea3a7f92ba9cde42172582dee to your computer and use it in GitHub Desktop.
class DefaultCustomClearButtonTable extends React.Component {
handleClearButtonClick = (onClick) => {
// Custom your onClick event here,
// it's not necessary to implement this function if you have no any process before onClick
console.log('This is my custom function for ClearSearchButton click event');
onClick();
}
createCustomClearButton = (onClick) => {
return (
<ClearSearchButton
btnText='MyClear'
btnContextual='btn-warning'
className='my-custom-class'
onClick={ e => this.handleClearButtonClick(onClick) }/>
);
// If you want have more power to custom the child of ClearSearchButton,
// you can do it like following
// return (
// <ClearSearchButton
// btnContextual='btn-warning'
// className='my-custom-class'
// onClick={ () => this.handleClearButtonClick(onClick) }>
// { ... }
// </ClearSearchButton>
// );
}
render() {
const options = {
clearSearch: true,
clearSearchBtn: this.createCustomClearButton
};
return (
<BootstrapTable data={ products } options={ options } search>
<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