Created
November 15, 2016 12:51
-
-
Save AllenFang/695f2c2310d57028166a9cfd5af7b61a to your computer and use it in GitHub Desktop.
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
| class MySearchField extends React.Component { | |
| // It's necessary to implement getValue | |
| getValue() { | |
| return ReactDOM.findDOMNode(this).value; | |
| } | |
| // It's necessary to implement setValue | |
| setValue(value) { | |
| ReactDOM.findDOMNode(this).value = value; | |
| } | |
| render() { | |
| return ( | |
| <input | |
| className={ `form-control` } | |
| type='text' | |
| defaultValue={ this.props.defaultValue } | |
| placeholder={ this.props.placeholder } | |
| onKeyUp={ this.props.search }/> | |
| ); | |
| } | |
| } | |
| class FullyCustomSearchFieldTable extends React.Component { | |
| render() { | |
| const options = { | |
| clearSearch: true, | |
| searchField: (props) => (<MySearchField { ...props }/>) | |
| }; | |
| 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