I made a table/accordion thing that has hidden rows that are only visible when you click the "header" row. Unfortunately, the table only displays a ONE row for each header you click.
jsfiddle
As you can see in the code, each header row (ex: "9 / Parts Inspection") has two sub rows that are hidden (ex: "9.1" and "9.2"). When you click, only the first one (9.1) appears, leaving the others (9.2 and any others I add) hidden when they are supposed to be shown.
I'm assuming it's a problem with the class/id names getting confused, but no matter what different names I give things, it still doesn't work.
<table id="tbl-sample-values" class="table table-condensed table-bordered table-hover" style="font-size:85%;">
<thead>
<tr class="tabletop">
<th>Step #</th>
<th>Processing Step</th>
<th>Barcode</th>
</tr>
</thead>
<tbody>
<tr data-toggle="collapse" data-target="#accordion" class="clickable row-header">
<td>9</td>
<td colspan="2">Parts Inspection</td>
</tr>
<tr id="accordion" class="collapse">
<td>9.1</td>
<td>Handle silicon electrodes...</td>
<td>[Barcode here]</td>
</tr>
<tr id="accordion" class="collapse">
<td>9.2</td>
<td>Verify part number...</td>
<td>[Barcode here]</td>
</tr>
<tr data-toggle="collapse" data-target="#accordion2" class="clickable row-header">
<td>10</td>
<td colspan="2">IPA Clean</td>
</tr>
<tr id="accordion2" class="collapse">
<td>10.1</td>
<td>Place part with frontside facing up...</td>
<td>[Barcode here]</td>
</tr>
<tr id="accordion2" class="collapse">
<td>10.2</td>
<td>Wipe the part using cleanroom wiper...</td>
<td>[Barcode here]</td>
</tr>
</tbody>
</table>
Give your tr's the same class instead of an unique id. Use this class as your data-target. For example:
<tr data-toggle="collapse" data-target=".my-row" class="clickable row-header">
<td>9</td>
<td colspan="2">Parts Inspection</td>
</tr>
<tr id="accordion" class="my-row collapse">
<td>9.1</td>
<td>Handle silicon electrodes...</td>
<td>[Barcode here]</td>
</tr>
<tr id="accordion" class="my-row collapse">
<td>9.2</td>
<td>Verify part number...</td>
<td>[Barcode here]</td>
</tr>
I hope this helps.
Related
I am loading some table content with collapse-panel, its in tabular format - like there are three rows and three columns , if i click on first column of first row which is header of that row , it expands and show its details, which again in tabular format,
image attached - before expanding
second image is when i click on orders , it expands and show its details.
the problem is .. when it expands , it shows its detailed table data only in its own column , as in image you can see "fsdfdsfds" column is excluded, i am trying to do that when it expands and show the details , it should show in a full row just below the entire row of main header ..
please see the code , any help ??
<table class="table">
<tr>
<td>
<a class="btn btn-default hide_retail" data-toggle="collapse" href="#show_retail" id="hide_retail">Orders</a>
<div id="show_retail" class="panel-collapse collapse">
<div class="panel-body">
dsfsdfd
<table class="table">
<tr>
<td>sdfdsf</td>
<td>sfsdf</td>
<td>dsfsdf</td>
<td>sdfdsf</td>
<td>sdfdsf</td>
<td>sfsdf</td>
<td>dsfsdf</td>
<td>sfsdf</td>
<td>dsfsdf</td>
</tr>
<tr>
<td>sdfdsf</td>
<td>sfsdf</td>
<td>dsfsdf</td>
<td>sdfdsf</td>
<td>sdfdsf</td>
<td>sfsdf</td>
<td>dsfsdf</td>
<td>sfsdf</td>
<td>dsfsdf</td>
</tr>
<tr>
<td>sdfdsf</td>
<td>sfsdf</td>
<td>dsfsdf</td>
<td>sdfdsf</td>
<td>sdfdsf</td>
<td>sfsdf</td>
<td>dsfsdf</td>
<td>sfsdf</td>
<td>dsfsdf</td>
</tr>
</table>
</div>
</div>
</td>
<td>fsdfdsfds</td>
<tr>
<td>fdsdf</td>
<td>fddsfd</td>
UPDATE : SOLVED -- i got the solution -- here-- > https://www.bootply.com/glebkema/Qyh5hbEMdU
You have to change structure of your HTML, here is the table what you asked,
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0-rc1/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0-rc1/js/bootstrap.min.js"></script>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Column</th>
<th>Column</th>
</tr>
</thead>
<tr data-toggle="collapse" data-target="#r1">
<td>Data</td>
<td>Data</td>
</tr>
<tr id="r1" class="collapse out">
<td>
Table inside the td
<table class="table">
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
</table>
</td>
<td>- Child column 2</td>
</tr>
<tr data-toggle="collapse" data-target="#r2">
<td>Data</td>
<td>Data</td>
</tr>
<tr id="r2" class="collapse out">
<td> - Child column 1</td>
<td>- Child column 2</td>
</tr>
</table>
I am using the following HTML/Razor to create a details row for when the user clicks the Run App button. The primary row is 4 columns wide, and the details row spans the 4 columns.
Detail Row Hidden
Detail visible
Here the detail row causes the table to expand really weirdly, it's way to large. It's not center either for some reason.
Small Table looks correct
It all looks fine when I reduce the size of the table. It's centered correctly and doesn't look super wide.
This is the HTML and a Fiddle
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<table class="table table-hover table-responsive">
<thead>
<tr>
<th>Components</th>
<th>Name</th>
<th>Description</th>
<th>Options</th>
</tr>
</thead>
<tbody>
<tr>
<td>Data Access,Querying</td>
<td>Basic Querying</td>
<td>Executes a stored procedure, fetching a single result set, without sending data in to the database.</td>
<td>
<button type="button" data-app="5625ad80-a1c7-4dfd-baeb-744d4de5292e" data-vm-required="False" class="btn btn-success">
Run App
</button>
</td>
</tr>
<tr class="">
<td colspan="4">
<div class="container">
<div class="alert alert-info" data-app="5625ad80-a1c7-4dfd-baeb-744d4de5292e">
<div class="container">
<span>
1000 items returned. Only showing the first 10 results.
<table class="table table-responsive">
<tbody>
<tr>
<th>PostalCode</th>
<th>City</th>
<th>AddressLine2</th>
<th>AddressLine1</th>
<th>AddressID</th>
</tr>
<tr>
<td>98011</td>
<td>Both</td>
<td></td>
<td>1970 Napa Ct.</td>
<td>1</td>
</tr>
<tr>
<td>98018</td>
<td>Bothell68</td>
<td></td>
<td>9833 Mt. Dias Blv.686</td>
<td>2</td>
</tr>
<tr>
<td>98011</td>
<td>Bothell</td>
<td></td>
<td>7484 Roundtree Drive</td>
<td>3</td>
</tr>
<tr>
<td>98011</td>
<td>Bothell</td>
<td></td>
<td>9539 Glenside Dr</td>
<td>4</td>
</tr>
<tr>
<td>85323</td>
<td>Phoenix</td>
<td></td>
<td>1226 Shoe St.</td>
<td>5</td>
</tr>
<tr>
<td>98011</td>
<td>Bothell</td>
<td></td>
<td>1399 Firestone Drive</td>
<td>6</td>
</tr>
<tr>
<td>98011</td>
<td>Bothell</td>
<td></td>
<td>5672 Hale Dr.</td>
<td>7</td>
</tr>
<tr>
<td>98011</td>
<td>Bothell</td>
<td></td>
<td>6387 Scenic Avenue</td>
<td>8</td>
</tr>
<tr>
<td>98011</td>
<td>Bothell</td>
<td></td>
<td>8713 Yosemite Ct.</td>
<td>9</td>
</tr>
<tr>
<td>98011</td>
<td>Bothell</td>
<td></td>
<td>250 Race Court</td>
<td>10</td>
</tr>
</tbody>
</table>
</span>
</div>
</div>
</div>
</td>
</tr>
<tr>
<td>Data Access,Querying</td>
<td>Parameterized Query</td>
<td>Executes a stored procedure, fetching a single result set, filtered by a City passed into the stored procedure.</td>
<td>
<button type="button" data-app="544abdf8-3685-4865-84f5-3d8fd132dd75" data-vm-required="True" data-app-name="Parameterized Query" data-toggle="modal" data-target="#appParameters" class="btn btn-success">
Run App
</button>
</td>
</tr>
<tr class="hidden">
<td colspan="4">
<div class="container">
<div class="alert alert-info" data-app="544abdf8-3685-4865-84f5-3d8fd132dd75">
</div>
</div>
</td>
</tr>
</tbody>
</table>
What am I doing wrong with the table that's causing it to not look like the way it does at the smaller Window scale?
Remove container class here and it will work normally.
<div class="container">
<span>
1000 items returned. Only showing the first 10 results.
I currently have a table with multiple rows. I was wondering if there is a way to collapse several rows (i.e. BMW, Toyota, and Honda) under the first row (i.e. cars) with out remove the "colspan" spacing. All the example I have seen seems like you have to lose the formatting of the collapsed rows.
<table class="table table-sm table-hover">
<thead class="thead-inverse">
<thead>
<tr>
<th colspan="6"></th>
<th colspan="3">Current Month</th>
<th colspan="3">Year-to-Date</th>
</tr>
</thead>
<tbody>
<tr data-toggle="collapse" data-target="#cars" class="accordion-toggle">
<th colspan="6">Cars</th>
<td colspan="3">456 mi</td>
<td colspan="3">700 mi</td>
</tr>
<tr class="hiddenRow"><div class="accordian-body collapse" id="cars">
<td colspan="1"></td>
<td colspan="5">Toyota</td>
<td colspan="3">534 mi</td>
<td colspan="3">800 mi</td>
</tr>
<tr>
<th colspan="1"></th>
<th colspan="5">Honda</th>
<td colspan="3">600 mi</td>
<td colspan="3">770 mi</td>
</tr>
</div>
</tbody>
</table>
If you use bootstrap you probably already have jQuery loaded, so you could use it to query and hide the rows on click. Like this:
(function() {
$('#carsTable .toggle').on('click', function() {
$('#carsTable .hideableRow').toggleClass('hiddenRow');
});
})()
https://jsfiddle.net/q4w8062y/1/
Another possibility, not sure it would work as you want, is to put the "toggler-row" on another tbody or as <table>'s child, and use the collapse class on <tbody>. Like this:
https://jsfiddle.net/wkmmro89/1/
http://www.w3.org/TR/html-markup/table.html#table
I using this with bootstrap. Tables display fine but theres something wrong with the width of the thead and tbody rows, you can see they have a smaller width than the entire column.
IF you click the panel head you'll see the line temporarily being the correct size. How do I fix this.
<div class="panel panel-default">
<!-- Default panel contents -->
<div class="panel-heading" data-toggle="collapse" href="#collapse1">Shop 1</div>
<!-- Table -->
<table class="table collapse" id="collapse1">
<thead>
<tr>
<th>Number</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>this is a shop</td>
<td>Go to</td>
</tr>
</tbody>
</table>
</div>
Well your problem is that the no. of columns i.e. <th></th> elements in table head <thead> doesn't match the no. of columns in table body <tbody>.
So you need to put an extra <th></th> inside table head <thead> which could be blank like this -
Your code Fiddle
Updated Working Fiddle with code below -
<div class="panel panel-default">
<!-- Default panel contents -->
<div class="panel-heading" data-toggle="collapse" href="#collapse1">Shop 1</div>
<!-- Table -->
<table class="table collapse" id="collapse1">
<thead>
<tr>
<th>Number</th>
<th>Description</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>this is a shop</td>
<td>Go to</td>
</tr>
</tbody>
</table>
</div>
I am trying to prepare a simple mark sheet [as an example to demonstrate my requirement]. Am planning to have a collapsible div which will render all the mark details once it is expanded.
<div class="well">
<table class="table table-bordered"
style="background:#fff; margin-bottom:10px;">
<tbody>
<tr class="inverse">
<th> ID</th>
<th colspan="2"> Name</th>
</tr>
<tr>
<td>1</td>
<td>ABC</td>
<td>
<a class="btn btn-primary" data-toggle="collapse" href="#ID_1"
aria-expanded="false" >
Hide/Unhide
</a>
</td>
</tr>
<tr>
<td colspan="3">
<div class="collapse" id="ID_1">
<div class="well">
<table class="table table-hover table-bordered" style="background:#fff; margin-bottom:10px;">
<thead>
<tr class="inverse">
<th>Subject</th>
<th>Mark</th>
</tr>
</thead>
<tbody>
<tr>
<td>Physics </td>
<td>100</td>
</tr>
</tbody>
</table>
</div>
</div>
</td>
</tr>
<tr class="inverse">
<th> ID</th>
<th colspan="2"> Name</th>
</tr>
<tr>
<td>2</td>
<td>PQR</td>
<td>
<a class="btn btn-primary" data-toggle="collapse" href="#ID_2"
aria-expanded="false" >
Hide/Unhide
</a>
</td>
</tr>
<tr>
<td colspan="3">
<div class="collapse" id="ID_2">
<div class="well">
<table class="table table-hover table-bordered" style="background:#fff; margin-bottom:10px;">
<thead>
<tr class="inverse">
<th>Subject</th>
<th>Mark</th>
</tr>
</thead>
<tbody>
<tr>
<td>Chemistry</td>
<td>100</td>
</tr>
</tbody>
</table>
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
fiddle
But in this approach, when a section is not expanded, the row which encloses the collapsible div appears like a blank row in the table - which is quite misleading.
I am sure this is not the best way to render this sort of details.Would like to know what are the alternate UI options to render these details.
Use this CSS:
td[colspan="3"] {
padding: 0;
}
Fiddle