簡體   English   中英

jQuery DataTable創建問題

[英]jQuery DataTable creating issue

我需要填充DIV容器,即使用jQuery DataTable創建一個表。 問題是這個例子對我不起作用。 而不是格式化的表我看到沒有任何元素的jQuery DataTable插件的未格式化的表。

下面顯示的php文件位於main/tables文件夾中,而所有腳本都位於main/scripts/media

那么,我的代碼實際上有什么問題呢?

<?php
    include_once 'include/DatabaseConnector.php';
    $query2="SELECT * FROM resources;";
    $result2=DatabaseConnector::ExecuteQueryArray($query2);
?>

<script type="text/javascript" src="../scripts/media/js/jquery.dataTables.min.js"></script>
<script src="../scripts/media/js/jquery-ui.js" type="text/javascript"></script>
<script type="text/javascript" src="../scripts/media/js/complete.js"></script>
<script type="text/javascript" src="../scripts/media/jsjquery.dataTables.js"></script>
<script type="text/javascript" src="../scripts/media/js/jquery.dataTables.columnFilter.js"></script>
<script type="text/javascript">
$(document).ready(function() {
    $('#example').dataTable();
} );
</script>

<div>
<h1>Employees</h1>

    <table width="100%">
        <tr>
            <td> 
                <div class="scrollbar">
                <table id="example" border="0" cellspacing="2" cellpadding="2" width = "100%">
                    <thead>
                    <tr>
                        <th scope="col">Reg</th>
                        <th scope="col">Title</th>
                        <th scope="col">Availability</th>
                        <th scope="col">Latitude</th>
                        <th scope="col">Longitude</th>
                        <th scope="col">Average Speed (km/h)</th>
                    </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($result2 as $row):?>
                        <tr class="alternate">
                        <td><?php echo $row['resReg']; ?></td>
                        <td><?php echo $row['resTitle']; ?></td>
                        <td><?php echo $row['resAvailability'] ? 'Yes' : 'No';?></td>
                        <td><?php echo $row['resLatitude']; ?></td>
                        <td><?php echo $row['resLongitude']; ?></td>
                        <td><?php echo $row['resAvgSpeed']; ?></td>
                        </tr>
                        <?php endforeach;?>
                    </tbody>
                </table>
                </div>
            </td>
        </tr>
    </table>
</div>

您缺少css文件。 添加它,你的問題應該解決。

我認為你需要添加主jquery文件。 喜歡;

<script src="js/jquery-1.10.2.min.js"></script>

* jQuery UI與jQuery庫文件不同。 並檢查這兩個文件是否重復。 如果是這樣,你只需要一個。

<script type="text/javascript" src="../scripts/media/js/jquery.dataTables.min.js"></script>

<script type="text/javascript" src="../scripts/media/jsjquery.dataTables.js"></script>

暫無
暫無

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

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