我正在使用Spring MVC
和DataTable with jQuery
来制作相关内容。
当没有数据可用时,我收到以下错误。
DataTables warning (table id='results'): Requested unknown parameter '1' from the data source for row 0
我在互联网上搜索,发现列数可能不匹配,但事实并非如此。但是,有时,数据为空/空,因此在UI中无需呈现任何内容。在这种情况下,我们甚至不显示表格。
但是这个错误始终存在。我刚开始使用DataTables并使用默认行为:
jq(document).ready( function(){
jq("#results").dataTable();
});
我的表格代码如下:
<table border="1" style="font-size:12px;width: 868px; table-layout: fixed; word-wrap: break-word;border-collapse: collapse" id='results'>
<thead>
<tr>
<th>Batch Name</th>
<th>Batch User</th>
<th>Total URL Count</th>
<th>Submitted URL Count</th>
<th>Processed URL Count</th>
<th>Submission Time</th>
<th>Batch Status</th>
<th>Download Link</th>
</tr>
</thead>
<tbody id="orderbody">
<tr id="pattern" style="display:none" >
<td width="15%"><span id="ibatchName">Batch Name</span></td>
<td width="15%"><span id="ibatchUser">Batch User</span></td>
<td width="11%"><span id="iTotalUrlCount" >Total URL Count</span></td>
<td width="11%"><span id="iSubmittedURLCount" >Submitted URL Count</span></td>
<td width="11%"><span id="iProcessedURLCount">Processed URL Count</span></td>
<td width="11%"><span id="iSubmissionTime" >Submission Time</span></td>
<td width="11%"><span id="ibatchStatus" >Batch Status</span></td>
<td width="15%"><span id="iDownloadLink" >Download Link</span></td>
</tr>
<c:choose>
<c:when test="${ not empty batches}">
<c:forEach var='batchDetail' items='${batches}'>
<tr id="pattern0">
<td>${batchDetail.batchName}</td>
<td>${batchDetail.batchUser}</td>
<td>${batchDetail.totalUrlCount}</td>
<td>${batchDetail.submittedUrlCount}</td>
<td>${batchDetail.processedUrlCount}</td>
<td>${batchDetail.submissionTimeFormatted}</td>
<td>${batchDetail.batchStatus}</td>
<td>${batchDetail.downloadLink}</a></td>
</tr>
</c:forEach>
</c:when>
<c:otherwise>
<tr id="pattern0">
<td colspan="8"><span class="batch_not_found">You are not authorized to see any of the batches. </span></td>
</tr>
</c:otherwise>
</c:choose>
</tbody>
</table>
我该怎么办?有没有办法在没有提取数据时禁用此警告?
谢谢,
答案 0 :(得分:1)
我自己得到了答案!
<tr id="pattern0">
<td colspan="8"><span class="batch_not_found">You are not authorized to see any of the batches. </span></td>
</tr>
是个问题。 DataTable无法呈现它。把它移到桌子外面就可以了。