I am currently facing a challenge with rearranging my table due to width constraints. My goal is to apply Jquery functions to the table in order to extract all parameters related to a product, but I want to avoid having nested tr elements or splitting parameters across multiple rows.
https://i.sstatic.net/HWypn.png
How can this be achieved?
<table style="width: 300px">
<thead>
<tr>
<th rowspan="2">Product</th>
<th>Category</th>
<th>Sub Category</th>
<th>Quantity</th>
<th>Arrival Date</th>
<th>Manufactured Date</th>
<th>Expiry Date</th>
</tr>
</thead>
<tbody>
<tr id="productID_1">
<td rowspan="2">Skimmed Milk</td>
<td>Dairy</td>
<td>Milk</td>
<td>1 Ltr</td>
<td>1st Jan 2018</td>
<td>1st Jan 2018</td>
<td>7th Jan 2018</td>
</tr>
<tr id="productID_2">
<td rowspan="2">Cheddar</td>
<td>Dairy</td>
<td>Cheese</td>
<td>200 Grms</td>
<td>1st Jan 2018</td>
<td>1st Jan 2018</td>
<td>15th Jan 2018</td>
</tr>
<tr id="productID_3">
<td rowspan="2">Vanilla Ice Cream</td>
<td>Desserts</td>
<td>Ice Creams</td>
<td>100 Grms</td>
<td>15th Jan 2018</td>
<td>1st Jan 2018</td>
<td>31st March 2018</td>
</tr>
</tbody>
</table>
Here is a snippet of my JQuery code:
$("table#customerSalesTable tbody tr").each(function(index){
// Code to capture each parameter
}
-- Update
Based on @CodeIt's suggestion, opting not to split single row into two rows and capturing values using classes would entail significant re-editing of my JS code.