我正在使用1.0.1版本的蒲公英-蒂梅莱。下面是我的蒲公英数据表的定义。表中有3个固定列,后面是在页面呈现时添加的一些列。
<table class="reportTable" dt:table="true" dt:pageable="false" dt:filterable="false" dt:processing="false" dt:serverside="false">
<thead>
<tr>
<th>Day</th>
<th>No of calls</th>
<th>Duration</th>
<th:block th:each="sb : ${timePeriodColumns}">
<th th:text="${sb}">x</th>
</th:block>
</tr>
</thead>
<tbody>
<tr th:each="sb : ${monthCallsByTimePeriod}">
<td th:text="${sb.day}">x</td>
<td th:text="${sb.numberOfCallsPerDay}">x</td>
<td th:text="${sb.callDurationPerDayInMinutes}">x</td>
<th:block th:each="tp : ${sb.dataForTimePeriod}">
<td th:text="${tp.numberOfCalls}">x</td>
<td th:text="${tp.callDurationInMinutes}">x</td>
</th:block>
</tr>
</tbody>
</table>表以HTML的形式呈现,但是当Dandelion试图应用Datatable时,我在jquery.dataTables.js中得到javascript错误jquery.dataTables.js,在这里我可以看到它在表的列中迭代,在调试时我可以看到oSettings.aoColumns中只有3条固定列。因此,当遇到第一个动态添加的列时,当它处理来自TBODY的数据时,会发生错误,因为Datatable不“知道”非固定列。
如果我省略了TBODY部件(所以只有表的THEAD部分呈现),错误就不会发生,但是我可以看到固定列有Datatable的排序控件,而非固定列没有这些控件,就好像它们被排除了一样。但是,查看HTML源代码,我看不到这些列之间的区别:
<thead>
<tr>
<th>Day</th>
<th>No of calls</th>
<th>Duration</th>
<th>Added col1</th>
<th>Added col2</th>
</tr>
</thead>我做错了什么?如何在呈现时向添加一些列?
发布于 2017-05-30 20:12:15
作为解决办法,我将前三列添加到timePeriodColumns列表中,并将其留给Thymeleaf来呈现<th th:each ...>中的所有列:
<thead>
<tr>
<th th:each="sb : ${timePeriodColumns}" th:text="${sb}">x</th>
</tr>
</thead>我怀疑使用<th:block ...>存在问题,但我无法证明这一点。不管怎样,这解决了我的问题。
https://stackoverflow.com/questions/44250651
复制相似问题