Each table row will have to allow the user to click it and get a subset of information pertaining to that row. I did a bit of searching and found this thread: Twitter Bootstrap Use collapse.js on table cells [Almost Done]
I got this solution sorta working on my code but I am having an issue where I am only getting one hidden row that displays at the bottom of the table as the last row, instead of under each individual row being mapped over from the grapevine array.
Here is my code:
<div className="card-block">
<Table hover bordered>
<thead>
<tr className="table-heading">
<th className="table-header">Entity</th>
<th className="table-header">Category</th>
<th className="table-header">Source</th>
<th className="table-header">Risk Score</th>
</tr>
</thead>
<tbody>
{this.state.gvEntries.map(grapevine => (
<tr data-toggle="collapse" data-target="#demo1" className="accordion-toggle">
<td>{grapevine.entity}</td>
<td>{grapevine.category}</td>
<td>{grapevine.source}</td>
<td>{grapevine.rscore}</td>
</tr>
))}
<tr >
<td colSpan="6" className="hiddenRow"><div className="accordian-body collapse" id="demo1"> Demo1 </div></td>
</tr>
</tbody>
</Table>
</div>
Any help would be appreciated, thanks!
2
Answers
The tr holding the hidden row should move inside of the map function and the data-target attribute and the id should be variables (ex the index)
something like: