I'm using this table component with radioboxes (Row selection(Single)) and I want to update the react state to the currently selected row.
A function called onRowSelect shows the row selected. To update the state to the row selected, I created a function called showRow(), which is called in onRowSelect. However, I keep getting a this.showRow() is not a function error.
I'm using showRow() outside the render function because I need to update the state with the currently chosen row.
class ChooseRowExample extends Component {
constructor(props) {
super(props);
this.state =({
chosenRow:""
});
this.showRow = this.showRow.bind(this);
}
showRow(row, isSelected){
console.log(row);
//update state here
}
render() {
var selectRowProp = {
mode: "radio",
clickToSelect: true,
bgColor: "#A7EC57",
onSelect: onRowSelect
};
function onRowSelect(row, isSelected){
this.showRow(row, isSelected);
}
return (
<div>
<BootstrapTable data={person} search={true} selectRow={selectRowProp}>
<TableHeaderColumn dataField="id" isKey={true}>Client #</TableHeaderColumn>
<TableHeaderColumn dataField="name">Company</TableHeaderColumn>
<TableHeaderColumn dataField="contact_name">Client Name</TableHeaderColumn>
</BootstrapTable>
</div>
)
}
}