我正在构建一个表,该表将显示由组成的行
年-月总计(sum())
单击该行时,bootstrap会展开该行,并显示一个嵌套表,其中包含与该月份和年份相关的更详细的数据行。
我相信我正确地掌握了来自控制器的数据。我需要做一个查询来获得每个月的年、月和sum()总数。
然后我执行find()来获取子行。
它们都被传递到totalResiduals数组。
我的html/视图看起来像这个
<div id="residuals" class="tab-pane">
<table class="table table-striped-yellow table-bordered table-condensed">
<thead>
<th>Year</th>
<th>Month</th>
<th>Total</th>
</thead>
<?php foreach($totalResiduals as $year => $monthResiduals): ?>
<?php foreach($monthResiduals as $month => $residuals): ?>
<tr data-toggle="collapse" data-parent="#accordion" href="#<?php echo $month; ?>" aria-expanded="false" style="cursor:pointer;">
<td><?php echo $year; ?></td>
<td><?php echo $month; ?></td>
<td><?php echo $residuals['paidTotal'];?></td>
</tr>
<tr id="<?php echo $month; ?>" class="collapse">
<td>
<table>
<thead>
<th>Product Type</th>
<th>Product Group</th>
<th>Volume</th>
<th>Paid</th>
</thead>
<?php foreach($residuals['residuals'] as $residual); ?>
<tr>
<td><?php echo $residual['product_type'] ?></td>
<td><?php echo $residual['product_group'] ?></td>
<td><?php echo $residual['volume'] ?></td>
<td><?php echo $residual['paid'] ?></td>
</tr>
<?php endforeach; ?>
</table>
</td>
</tr>
<?php endforeach; ?>
</table>
最终发生的是,这些行一直以折叠嵌套行的形式结束。最初将显示1行,单击它,将打开1个子/嵌套行。单击该按钮,将打开1个主行,但嵌套/折叠在该子行中。
我想发生的事情看起来有点像这样:
年度月合计2015年4$30Type Group Volume Payed产品产品0.00美元10.00美元产品产品0.00美元10.00美元产品产品0.00美元10.00美元2015年5$50Type Group Volume Payed产品产品0.00美元25.00美元产品产品0.00美元25.00美元
我认为我的错误在我看来,所以请让我知道我还可以提供哪些我遗漏的信息。
这是我的数据的打印
Array
[2015] => Array
(
[1] => Array
(
[paidTotal] => 11.47
[residuals] => Array
(
[0] => Array
(
[product_type] => HRV Residuals
[product_group] => HRV Residuals
[volume] => 0.00
[paid] => 11.47
)
)
)
[2] => Array
(
[paidTotal] => 5.77
[residuals] => Array
(
[0] => Array
(
[product_type] => HRV Residuals
[product_group] => HRV Residuals
[volume] => 0.00
[paid] => 5.77
)
)
)
[4] => Array
(
[paidTotal] => 30.47
[residuals] => Array
(
[0] => Array
(
[product_type] => HRV Residuals
[product_group] => HRV Residuals
[volume] => 0.00
[paid] => 12.06
)
[1] => Array
(
[product_type] => HRV Residuals
[product_group] => HRV Residuals
[volume] => 0.00
[paid] => 5.83
)
[2] => Array
(
[product_type] => HRV Residuals
[product_group] => HRV Residuals
[volume] => 0.00
[paid] => 12.58
)
)
)
提前感谢
Steven
乍一看,这不应该阻止吗
<tr data-toggle="collapse" data-parent="#accordion" href="#<?php echo $month; ?>" aria-expanded="false" style="cursor:pointer;">
<td><?php echo $year; ?></td>
<td><?php echo $month; ?></td>
<td><?php echo $residuals['paidTotal'];?></td>
</tr>
,在此之外
<?php foreach($monthResiduals as $month => $residuals): ?>
,像一样
<?php foreach($totalResiduals as $year => $monthResiduals): ?>
<tr data-toggle="collapse" data-parent="#accordion" href="#<?php echo $month; ?>" aria-expanded="false" style="cursor:pointer;">
<td><?php echo $year; ?></td>
<td><?php echo $month; ?></td>
<td><?php echo $residuals['paidTotal'];?></td>
</tr>
<?php foreach($monthResiduals as $month => $residuals): ?>