将具有相同 ID 的两行合并为两个子行

时间:2021-05-26 14:18:37

标签: css bootstrap-4 asp.net-core-mvc accordion

所以我试图用我的数据库中的所有数据在手风琴表中制作一个表。 我试图显示的数据是“错误”数据,因此我的数据库中的数据可能如下所示:

<头>
起源 位置 问题
工厂A 位置 A Y 是问题
工厂A 位置 B Z 有问题
B 厂 位置 C X 是问题(我只是在这里澄清)

所以数据库的工作方式是这样,它存储某个位置的问题。所以假设工厂 A 在位置 A 有问题,然后它如上存储它,并带有一条小消息,说“这是一个问题” 并且,如果工厂 A 出现另一个问题,它就会变成一个新的行。希望表格能解释这种磨难。

现在,我的问题是我想在一个手风琴表中显示我的数据,有多个子行。 例如,A 工厂可能有 5 个问题。 所以我想实现一个下拉列表,你可以去那里。

  1. A 工厂

    1.1 问题 Y

    1.1.1 Information about the problem.
    

    1.2 问题 Z

所以我遇到的主要问题是,我如何将来自工厂 A 的数据分组,以便我可以在其下方的子行中显示它?

Current solution

我的 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>

我试图尽可能地简化一切。将不胜感激,只是指出了正确的方向。 提前致谢!

0 个答案:

没有答案