1

我正在使用Spring MVCandDataTable 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>

我该怎么办?当没有获取数据时,有什么方法可以禁用此警告?

谢谢,

4

1 回答 1

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 无法呈现它。把它移到桌子外面,它起作用了。

于 2012-12-24T14:13:03.177 回答