I have a web page that uses Bootstrap 3. In that page, I have a table that looks like this:
<table class="table">
<thead>
<tr>
<th></th>
<th>Order Number</th>
<th>Order Date</th>
<th>Total Price</th>
</tr>
</thead>
<tbody>
<tr>
<td>></td>
<td>1001</td>
<td>9/29/2016</td>
<td>$126.27</td>
</tr>
<tr>
<td>></td>
<td>1002</td>
<td>9/27/2016</td>
<td>$92.15</td>
</tr>
<tr>
<td>></td>
<td>1003</td>
<td>9/01/2016</td>
<td>$23.55</td>
</tr>
</tbody>
</table>
You can see what this table looks like here. When a user clicks the >, I want to expand the row. At that point, more rows should appear to show each orders details. For example, if I expand the middle row, I should see the following:
+-----------------------------------------------------------------+
Order Number Order Date Total Price
+-----------------------------------------------------------------+
1001 09/29/2016 $126.27
+-----------------------------------------------------------------+
1002 09/27/2016 $92.15
+-----------------------------------------------------------------+
Shirt $21.87
+-----------------------------------------------------------------+
Shoes $70.28
+-----------------------------------------------------------------+ 1003 09/01/2016 $23.55
+-----------------------------------------------------------------+
The key thing in this table is that when I expand an order, I'm trying to show the items in the order. Each item needs to be in its own row. That has caused me some challenges. I tried using the collapse ponent. However, that only works if I want to show/hide a div. Plus, it throw the styling of my table off.
How do I show / hide child rows in a table, and still keep the bootstrap style?
I have a web page that uses Bootstrap 3. In that page, I have a table that looks like this:
<table class="table">
<thead>
<tr>
<th></th>
<th>Order Number</th>
<th>Order Date</th>
<th>Total Price</th>
</tr>
</thead>
<tbody>
<tr>
<td>></td>
<td>1001</td>
<td>9/29/2016</td>
<td>$126.27</td>
</tr>
<tr>
<td>></td>
<td>1002</td>
<td>9/27/2016</td>
<td>$92.15</td>
</tr>
<tr>
<td>></td>
<td>1003</td>
<td>9/01/2016</td>
<td>$23.55</td>
</tr>
</tbody>
</table>
You can see what this table looks like here. When a user clicks the >, I want to expand the row. At that point, more rows should appear to show each orders details. For example, if I expand the middle row, I should see the following:
+-----------------------------------------------------------------+
Order Number Order Date Total Price
+-----------------------------------------------------------------+
1001 09/29/2016 $126.27
+-----------------------------------------------------------------+
1002 09/27/2016 $92.15
+-----------------------------------------------------------------+
Shirt $21.87
+-----------------------------------------------------------------+
Shoes $70.28
+-----------------------------------------------------------------+ 1003 09/01/2016 $23.55
+-----------------------------------------------------------------+
The key thing in this table is that when I expand an order, I'm trying to show the items in the order. Each item needs to be in its own row. That has caused me some challenges. I tried using the collapse ponent. However, that only works if I want to show/hide a div. Plus, it throw the styling of my table off.
How do I show / hide child rows in a table, and still keep the bootstrap style?
Share Improve this question edited Mar 19, 2020 at 8:55 Mosh Feu 29.3k18 gold badges93 silver badges141 bronze badges asked Sep 29, 2016 at 16:12 user687554user687554 11.1k26 gold badges81 silver badges142 bronze badges1 Answer
Reset to default 11The collapse ponent should work for you, just make sure you override it's normal display:block
with display:table-row
like this..
tr.collapse.in {
display:table-row;
}
Demo: http://www.bootply./NKtIQVbETH