I am using react-modal and react-bootstrap-table2 to display row's values in a modal.
Right now the modal displays the last rows values regardless of row clicked. How do I make sure the each modal displays its own rows data?
renderButtons = (cell, row, rowIndex) => {
return (
<span>
<button onClick={this.openModal}>Details</button>
<Modal
isOpen={this.state.modalIsOpen}
onAfterOpen={this.afterOpenModal}
onRequestClose={this.closeModal}
style={customStyles}
contentLabel="Example Modal"
>
<div>
<h2 ref={subtitle => (this.subtitle = subtitle)}>{cell} title</h2>
<button onClick={this.closeModal}>close</button>
{cell}- {row.name}
{row.record_type}: {row.specific_type}: {row.health_name}
</div>
</Modal>
</span>
);
};
renderButtons is used in the table:
renderRecordsTable() {
const records = this.props.records;
const isPerson = this.props.recordable_type == 'user';
const columns = [
{
dataField: 'id',
formatter: this.renderButtons,
text: '',
headerTitle: false
}
];
return (
<BootstrapTable
keyField="id"
data={records}
columns={columns}
filter={filterFactory()}
/>
);
}
and in my components render
render() {
return (
<div name="records" className="content">
{this.renderRecordsTable()}
</div>
);
}