如何解决将具有相同 ID 的两行合并为两个子行
所以我试图用我的数据库中的所有数据在手风琴表中制作一个表。 我试图显示的数据是“错误”数据,因此我的数据库中的数据可能如下所示:
起源 | 位置 | 问题 |
---|---|---|
工厂A | 位置 A | Y 是问题 |
工厂A | 位置 B | Z 有问题 |
B 厂 | 位置 C | X 是问题(我只是在这里澄清) |
所以数据库的工作方式是这样,它存储某个位置的问题。所以假设工厂 A 在位置 A 有问题,然后它如上存储它,并带有一条小消息,说“这是一个问题” 并且,如果工厂 A 出现另一个问题,它就会变成一个新的行。希望表格能解释这种磨难。
现在,我的问题是我想在一个手风琴表中显示我的数据,有多个子行。 例如,A 工厂可能有 5 个问题。 所以我想实现一个下拉列表,你可以去那里。
-
A 工厂
1.1 问题 Y
1.1.1 information about the problem.
1.2 问题 Z
所以我遇到的主要问题是,我如何将来自工厂 A 的数据分组,以便我可以在其下方的子行中显示它?
我的 CSS 如下
<h2>Validation Results</h2>
<table class="table table-hover">
<thead class="thead-dark">
<tr>
<th scope="col">
Origin
</th>
<th scope="col">
Location
</th>
</tr>
</thead>
@foreach (var item in Model)
{
<tbody>
<tr data-toggle="tooltip" data-placement="top" title="Press the 'Plus' for more info!">
<th scope="row">
<a class="fas fa-plus-circle" role="button" data-toggle="collapse" data-target="#HiddenRow-@item.Origin" aria-expanded="true" aria-controls="HiddenRow"></a>
Factory A
</th>
<td>
Location A
</td>
</tr>
<tr>
<td colspan="12"style="padding: 0 !important">
<div class="collapse" id="HiddenRow-@item.Origin" aria-expanded="false">
<table class="table table-striped">
<thead>
<tr>
<th scope="col">Problem: </th>
<td>Problem Description</td>
</tr>
</thead>
</table>
</div>
</td>
</tr>
</tbody>
}
</table>
我试图尽可能地简化一切。将不胜感激,只是指出了正确的方向。 提前致谢!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。