I have a React Bootstrap table(http://allenfang.github.io/react-bootstrap-table/index.html) which will get populated from data coming in from an API. I want to add a button to one of the columns and then perform operations on it. For example, once the button is clicked in a particular row, I need to extract data from the particular row and then make an API call. How to the above using React Bootstrap table?
return (
<BootstrapTable
condensed={true}
data = { tableData }
//I use tableData to store information obtained from API
headerStyle={ {
background: '#FFF',
} }
containerStyle={ { background: '#FFF' } }
ref='table'
>
<TableHeaderColumn dataField='resourceId' isKey dataAlign='center' dataSort={ true }> ID </TableHeaderColumn>
<TableHeaderColumn dataField='Name' dataAlign='center'> Name </TableHeaderColumn>
<TableHeaderColumn dataField='support' dataAlign='center' dataSort={ true }> Support</TableHeaderColumn>
<TableHeaderColumn dataField='status' dataAlign='center' dataSort={ true }> Status</TableHeaderColumn>
<TableHeaderColumn
dataAlign='center'
options={
<button> Select </button>}
>
File Path
</TableHeaderColumn>
//Insert button here and access onClick property and make relevant API calls
</BootstrapTable>
Select you columns either by class or you can use a query selector
Loop through them adding the button to each. Edit properties of button as you see fit.
You can write a custom dataformatter:
And in the column: