簡體   English   中英

DataTable插件不適用於html表

[英]Datatable plugin not working on html table

我以前使用的插件是jQuery分頁,但由於它僅限於分頁,因此我決定切換到http://datatables.net上的插件,但是當我應用它時,就像本教程說的那樣,出現了一行sayng表中沒有可用數據,顯示0項中的0到0,這是我的html以及我如何嘗試解決此問題

<%@ include file="/template/jstl.jsp"%>
<html>
<title></title>
<head>
<script type="text/javascript" src="${ctx}/js/jquery/jquery-1.7.2.js"></script>
<script type="text/javascript" src="${ctx}/js/jquery/jPaginate.js"></script>
<script type="text/javascript" src="${ctx}/js/jquery/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="${ctx}/js/jquery/jquery.dataTables.js"></script>
<script type="text/javascript" src="${ctx}/js/device/device.js"></script>

</head>
<body>

<div class="titulo">Lista de Dispositivos</div>
    <table class="device" id="table_id">
        <thead>
            <tr>
                <th >Nome</th>
                <th >Código</th>
                <th >Ações</th>
                <th >Excluir</th>

            </tr>
        </thead>
        <tbody>
            <c:if test="${empty devices}">
                <tr>
                    <td colspan="4" align="center">                             
                         Nenhum dispositivo encontrado</td>
                </tr>
            </c:if>

        </tbody>
        <tbody id="tableholder" class="classholder">
        <c:forEach var="device" items="${devices}">
            <tr>
                <td><a href="<c:url value="/device/update/${device.id}"/>">${device.name}</a></td>
                <td><a href="<c:url value="/device/update/${device.id}"/>">${device.code}</a></td>
                <td><a href="<c:url value="/comandos/${device.id}"/>"><img src="${ctx}/images/comandos.png" alt="Comandos" title="Comandos"></a></td>
                <td><a id="${device.id}" class="delete" href="#"><input type="submit" id="excluir_button" value="" title="Excluir" /></a></td>
            </tr>
        </c:forEach>
        </tbody>
    </table>

</body>
</html>

這是我的JavaScript

jQuery(document).ready(function () {
    jQuery("#table_id").dataTable(); 
});

DataTables 不支持多個<tbody> -tags 此外,您的第一個<tbody>僅包含一個跨越四列的列,該列與<thead> -section不匹配,因此DataTables初始化失敗。 DataTables不了解colspanning。

另外,為什么同時使用jquery.dataTables.min.js jquery.dataTables.js

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM