gpt4 book ai didi

javascript - 如何扩展表格以在 AngularJS 中以 Accordion 样式添加更多信息

转载 作者:搜寻专家 更新时间:2023-11-01 04:24:17 25 4
gpt4 key购买 nike

我在完成这项工作时遇到了很多问题。本质上,我希望能够单击表格中的一行以展开该行并在其中提供其他信息。我希望它是一种切换式 Accordion 风格(抽屉),这样我就可以一次打开多个。代码如下。

<div class="row">
<div class="col-md-11">
<table class="table table-hover table-bordered">
<thead>
<tr>
<th>S</th>
<th>R</th>
<th>Se</th>
<th>D</th>
<th>Ser</th>
<th>L</th>
</tr>
</thead>

<tbody>
<tr ng-repeat="x in projects | filter:query | filter:quer | orderBy:orderProp">
<td><b>{{x.a}}</b></td>
<td>{{x.b}}</td>
<td><u>{{x.c}}</u></td>
<td>{{x.d}}</td>
<td>{{x.e}}</td>
<td>{{x.f}}</td>
</tr>
</tbody>
</table>
</div>
</div>

它形成一个有六列的表格,它将循环记录并产生多组信息。我希望能够让这些行能够在点击时展开和折叠。

http://plnkr.co/edit/CO7ZHudbfR9TZxGTQfGZ

谢谢。

最佳答案

您可以使用 angular-ui-bootstrap,它提供了一组基于 Twitter Bootstrap 标记和 CSS 的 AngularJS 指令,并使用 ng-repeat 遍历您的数据。在 <accordion> .

  <accordion-group  ng-repeat="x in pro | orderBy:orderProp">
<accordion-heading>
<div class="row">
<div class="cell"><b>{{x.a}}</b></div>
<div class="cell">{{x.b}}</div>
<div class="cell"><u>{{x.c}}</u></div>
<div class="cell">{{x.d}}</div>
<div class="cell">{{x.e}}</div>
<div class="cell">{{x.f}}</div>
</div>
</accordion-heading>

<div>
Test Data
</div>

</accordion-group>
</accordion>

此外,您还可以使用css来显示表格数据

.table{
display: table;
width:100%
}
.row{
display: table-row;
}
.cell{
display: table-cell;
width:20%
}

使用 ui-bootstrap 的优势在于,它提供了对原生 AngularJS 指令的访问,而不依赖于 jQuery 或 Bootstrap 的 JavaScript。

这是更新的 plunkr

关于javascript - 如何扩展表格以在 AngularJS 中以 Accordion 样式添加更多信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30935329/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com