【问题标题】:Adding Column to jQuery Datatables将列添加到 jQuery 数据表
【发布时间】:2014-06-06 16:51:23
【问题描述】:
我想在 jQuery 数据表中添加一列。它将用于为每一行包含一个删除按钮,就像我对另一个表一样。按钮图片和类在从数据库中检索表数据的 php 文件中是特定的。
只需在 html 中添加一列,因为以下内容会破坏页面上的 javascript:
<th>New Column</th>
我在 aoColumnDefs 设置中看不到任何对添加的列执行任何操作的内容。我需要在哪里添加或编辑哪些代码以适应新列?
我不是现有表格背后的原始开发者。
【问题讨论】:
标签:
javascript
php
jquery
html
datatables
【解决方案1】:
您可以从此处添加一个或多个 th,例如 Revenue2
<table class="mws-table">
<thead>
<tr>
<th>Date</th>
<th>Transaction ID</th>
<th>Segment</th>
<th>Revenue</th>
</tr>
</thead>
<tbody id="transactions">
<tr>
<td class="trDate"></td>
<td class="transactionId"></td>
<td class="segment"></td>
<td class="revenue"></td>
</tr>
</tbody>
<tfoot>
<tr class="customFooterRow">
<th>Total</th>
<th></th>
<th></th>
<th align ="left" class="revenueTotal"></th>
</tr>
</tfoot>
</table>
【解决方案2】:
您可能也忘记为正文添加列,如果您有“tfoot”,您还需要向其添加另一列。