Bootstrap 5 表格中的 rowspan 不起作用。

huangapple go评论58阅读模式
英文:

Rowspan in Bootstrap 5 table is not working

问题

我正在使用 Bootstrap 5 表格来展示数据(零件库存)。我有 4 种不同的零件参考,每种参考都有相同的原始参考。数据是通过 Puppeteer(网络爬取)"创建" 的。

我的表格代码如下所示:

<div class="container">
    <table class="table table-responsive mt-5 caption-top">
        <caption>Carreto Louco PK6<%=partDataPK[3].partName.substring(11,16)%>, <%=partDataPK[6].partName.substring(10,15)%>,
            <%=partDataPK[12].partName.substring(10,15)%>, <%=partDataPK[9].partName.substring(10,15)%>
        </caption>
        <thead class="align-middle table-group-divider">
            <tr>
                <th scope="col" class="text-center"></th>
                <th scope="col" class="text-center">PEÇA EM BRUTO</th>
                <th scope="col" class="text-center">PEÇA BRACA</th>
                <th scope="col" class="text-center">PEÇA NEGRA</th>
                <th scope="col" class="text-center">PEÇA ACABADA</th>
            </tr>
        </thead>
        <tbody class="table-group-divider">
            <!-- ... 中间部分 ... -->
        </tbody>
    </table>
</div>

现在我的表格外观如文件 "Bootstrap5_table_without_rowspan" 中所示。

由于每种零件有相同的原始零件参考和数量,我想应用 rowspan="4",但是当我这样做时没有任何变化。

然而,如果我应用 colspan="2",例如,它会按预期工作。

我期望表格的外观如图像文件 "Expected_Bootstrap5_table" 中所示。

我已经查阅了关于此问题的各种问题,但没有一个解决方案有效。

有人能指向解决方案并解释为什么 rowspan 不起作用吗?谢谢。

英文:

I'm using Bootstrap 5 table to present data (stock of parts). I have 4 different references for parts, each of them having the same RAW reference. The data is "created" by Puppeteer (web scraping).

My table code is as follows:

&lt;div class=&quot;container&quot;&gt;
&lt;table class=&quot;table table-responsive mt-5 caption-top&quot;&gt;
&lt;caption&gt;Carreto Louco PK6&#170; &lt;%=partDataPK[3].partName.substring(11,16)%&gt;, &lt;%=partDataPK[6].partName.substring(10,15)%&gt;,
&lt;%=partDataPK[12].partName.substring(10,15)%&gt;, &lt;%=partDataPK[9].partName.substring(10,15)%&gt;
&lt;/caption&gt;
&lt;thead class=&quot;align-middle table-group-divider&quot;&gt;
&lt;tr&gt;
&lt;th scope=&quot;col&quot; class=&quot;text-center&quot;&gt;&lt;/th&gt;
&lt;th scope=&quot;col&quot; class=&quot;text-center&quot;&gt;PE&#199;A EM BRUTO&lt;/th&gt;
&lt;th scope=&quot;col&quot; class=&quot;text-center&quot;&gt;PE&#199;A BRACA&lt;/th&gt;
&lt;th scope=&quot;col&quot; class=&quot;text-center&quot;&gt;PE&#199;A NEGRA&lt;/th&gt;
&lt;th scope=&quot;col&quot; class=&quot;text-center&quot;&gt;PE&#199;A ACABADA&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody class=&quot;table-group-divider&quot;&gt;
&lt;tr&gt;
&lt;th scope=&quot;row&quot; class=&quot;text-center&quot;&gt;
&lt;%=partDataPK[3].partName.substring(3,17)%&gt;
&lt;/th&gt;
&lt;td class=&quot;text-center&quot; tabindex=&quot;0&quot; data-html=&quot;true&quot; data-bs-toggle=&quot;tooltip&quot; data-bs-placement=&quot;top&quot;
data-bs-title=&quot;Refer&#234;ncia: &lt;%= partDataPK[0].ref %&gt;&quot;&gt;
&lt;%=partDataPK[0].partQty%&gt;
&lt;/td&gt;
&lt;td class=&quot;text-center&quot; tabindex=&quot;0&quot; data-html=&quot;true&quot; data-bs-toggle=&quot;tooltip&quot; data-bs-placement=&quot;top&quot;
data-bs-title=&quot;Refer&#234;ncia: &lt;%= partDataPK[1].ref %&gt;&quot;&gt;
&lt;%=partDataPK[1].partQty%&gt;
&lt;/td&gt;
&lt;td class=&quot;text-center&quot; tabindex=&quot;0&quot; data-html=&quot;true&quot; data-bs-toggle=&quot;tooltip&quot; data-bs-placement=&quot;top&quot;
data-bs-title=&quot;Refer&#234;ncia: &lt;%= partDataPK[2].ref %&gt;&quot;&gt;
&lt;%=partDataPK[2].partQty%&gt;
&lt;/td&gt;
&lt;td class=&quot;text-center&quot; tabindex=&quot;0&quot; data-html=&quot;true&quot; data-bs-toggle=&quot;tooltip&quot; data-bs-placement=&quot;top&quot;
data-bs-title=&quot;Refer&#234;ncia: &lt;%= partDataPK[3].ref %&gt;&quot;&gt;
&lt;%=partDataPK[3].partQty%&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th scope=&quot;row&quot; class=&quot;text-center&quot;&gt;
&lt;%=partDataPK[6].partName.substring(3,17)%&gt;
&lt;/th&gt;
&lt;td class=&quot;text-center&quot; tabindex=&quot;0&quot; data-html=&quot;true&quot; data-bs-toggle=&quot;tooltip&quot; data-bs-placement=&quot;top&quot;
data-bs-title=&quot;Refer&#234;ncia: &lt;%= partDataPK[0].ref %&gt;&quot;&gt;
&lt;%=partDataPK[0].partQty%&gt;
&lt;/td&gt;
&lt;td class=&quot;text-center&quot; tabindex=&quot;0&quot; data-html=&quot;true&quot; data-bs-toggle=&quot;tooltip&quot; data-bs-placement=&quot;top&quot;
data-bs-title=&quot;Refer&#234;ncia: &lt;%= partDataPK[4].ref %&gt;&quot;&gt;
&lt;%=partDataPK[4].partQty%&gt;
&lt;/td&gt;
&lt;td class=&quot;text-center&quot; tabindex=&quot;0&quot; data-html=&quot;true&quot; data-bs-toggle=&quot;tooltip&quot; data-bs-placement=&quot;top&quot;
data-bs-title=&quot;Refer&#234;ncia: &lt;%= partDataPK[5].ref %&gt;&quot;&gt;
&lt;%=partDataPK[5].partQty%&gt;
&lt;/td&gt;
&lt;td class=&quot;text-center&quot; tabindex=&quot;0&quot; data-html=&quot;true&quot; data-bs-toggle=&quot;tooltip&quot; data-bs-placement=&quot;top&quot;
data-bs-title=&quot;Refer&#234;ncia: &lt;%= partDataPK[6].ref %&gt;&quot;&gt;
&lt;%=partDataPK[6].partQty%&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th scope=&quot;row&quot; class=&quot;text-center&quot;&gt;
&lt;%=partDataPK[12].partName.substring(3,17)%&gt;
&lt;/th&gt;
&lt;td class=&quot;text-center&quot; tabindex=&quot;0&quot; data-html=&quot;true&quot; data-bs-toggle=&quot;tooltip&quot; data-bs-placement=&quot;top&quot;
data-bs-title=&quot;Refer&#234;ncia: &lt;%= partDataPK[0].ref %&gt;&quot;&gt;
&lt;%=partDataPK[0].partQty%&gt;
&lt;/td&gt;
&lt;td class=&quot;text-center&quot; tabindex=&quot;0&quot; data-html=&quot;true&quot; data-bs-toggle=&quot;tooltip&quot; data-bs-placement=&quot;top&quot;
data-bs-title=&quot;Refer&#234;ncia: &lt;%= partDataPK[10].ref %&gt;&quot;&gt;
&lt;%=partDataPK[10].partQty%&gt;
&lt;/td&gt;
&lt;td class=&quot;text-center&quot; tabindex=&quot;0&quot; data-html=&quot;true&quot; data-bs-toggle=&quot;tooltip&quot; data-bs-placement=&quot;top&quot;
data-bs-title=&quot;Refer&#234;ncia: &lt;%= partDataPK[11].ref %&gt;&quot;&gt;
&lt;%=partDataPK[11].partQty%&gt;
&lt;/td&gt;
&lt;td class=&quot;text-center&quot; tabindex=&quot;0&quot; data-html=&quot;true&quot; data-bs-toggle=&quot;tooltip&quot; data-bs-placement=&quot;top&quot;
data-bs-title=&quot;Refer&#234;ncia: &lt;%= partDataPK[12].ref %&gt;&quot;&gt;
&lt;%=partDataPK[12].partQty%&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th scope=&quot;row&quot; class=&quot;text-center&quot;&gt;
&lt;%=partDataPK[9].partName.substring(3,17)%&gt;
&lt;/th&gt;
&lt;td class=&quot;text-center&quot; tabindex=&quot;0&quot; data-html=&quot;true&quot; data-bs-toggle=&quot;tooltip&quot; data-bs-placement=&quot;top&quot;
data-bs-title=&quot;Refer&#234;ncia: &lt;%= partDataPK[0].ref %&gt;&quot;&gt;
&lt;%=partDataPK[0].partQty%&gt;
&lt;/td&gt;
&lt;td class=&quot;text-center&quot; tabindex=&quot;0&quot; data-html=&quot;true&quot; data-bs-toggle=&quot;tooltip&quot; data-bs-placement=&quot;top&quot;
data-bs-title=&quot;Refer&#234;ncia: &lt;%= partDataPK[7].ref %&gt;&quot;&gt;
&lt;%=partDataPK[7].partQty%&gt;
&lt;/td&gt;
&lt;td class=&quot;text-center&quot; tabindex=&quot;0&quot; data-html=&quot;true&quot; data-bs-toggle=&quot;tooltip&quot; data-bs-placement=&quot;top&quot;
data-bs-title=&quot;Refer&#234;ncia: &lt;%= partDataPK[8].ref %&gt;&quot;&gt;
&lt;%=partDataPK[8].partQty%&gt;
&lt;/td&gt;
&lt;td class=&quot;text-center&quot; tabindex=&quot;0&quot; data-html=&quot;true&quot; data-bs-toggle=&quot;tooltip&quot; data-bs-placement=&quot;top&quot;
data-bs-title=&quot;Refer&#234;ncia: &lt;%= partDataPK[9].ref %&gt;&quot;&gt;
&lt;%=partDataPK[9].partQty%&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

Right now my table has the appearence shown in the file "Bootstrap5_table_without_rowspan" Bootstrap5_table_without_rowspan

Since the RAW part refence and, thus, quantity is the same for each of 4 references, i would like to apply rowspan=&quot;4&quot;, but when i do that nothing happens.

However, if i apply colspan=&quot;2&quot;, for example, it works as expected.

I am expecting to have the table with the appearence shown in the image file "Expected_Bootstrap5_table".Expected_Bootstrap5_table

I've consulted various questions about this issue here on StackOverflow by none of the solution worked.

Can someone point me to the solution and what is preventing rowspan from working?
Thanks in advance.

答案1

得分: 1

问题是每个表格行都包装在一个单独的表格主体元素中。当我移除了多余的表格主体时,它就正常工作了。

英文:

The problem was that each of table rows was wrapped in an individual table body element. When I removed extraneous table bodies, it worked.

huangapple
  • 本文由 发表于 2023年4月19日 18:08:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/76053254.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定