【发布时间】:2018-12-12 06:26:18
【问题描述】:
{% raw %}
<table class="table table-striped table-bordered row" id="compare-table" style = "table-layout: fixed; margin-right: auto; margin-left: auto">
<thead>
<th class = "col-md-3 tableHeading">Configuration name</th>
<th class = "col-md-3 tableHeading">Property Name</th>
<th class = "col-md-3 tableHeading">Value 1</th>
<th class = "col-md-3 tableHeading">Value 2 </th>
</thead>
<tbody>
{{#each tableRows }}
{{#each values}}
<tr>
{{#if @first}}
<th class="breakWord inlineHeading" rowspan={{../length}}>{{ ../pid }}</th>
{{/if}}
<td class="breakWord">{{ propName }}</td>
<td class="breakWord">{{ propValueA }}</td>
<td class="breakWord">{{ propValueB }}</td>
</tr>
{{/each}}
{{/each}}
</tbody>
</table>
{% endraw %}
我必须在 ajax 请求后动态呈现一个表,并希望按配置名称对行进行分组。当我在 Data Table 中使用 rowspan 时,只呈现简单的表并且出现控制台错误:
jquery.dataTables.min.js:24 Uncaught TypeError: Cannot set property '_DT_CellIndex' of undefined
我正在使用 handlebars.js 来填充表格模板
数据表: https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"> https://cdn.datatables.net/1.10.19/js/dataTables.bootstrap.min.js">
有没有办法在保留 Datatable 功能的同时以这种格式生成表格。
【问题讨论】:
-
这里面的javascript在哪里?
-
<th rowspan="2">Name</th>试试 -
@SumeshTG 我正在通过车把动态提供行跨度,但它会引发控制台错误,并且会呈现一个简单的 html 表格,而没有分页、搜索和排序功能
-
@SamzSakerz 我已经直接用cdn链接导入Datatable了,想知道会使用js的rowspan的解决方案。我是 js 新手,需要帮助解决这个问题。请建议是否应该对帖子进行任何编辑。谢谢
标签: javascript jquery html datatables handlebars.js