Jquery DataTable不显示数据

时间:2016-05-18 19:36:35

标签: jquery datatables

我的代码:

var dataSet = [
     ["Tiger Nixon", "System Architect", "Edinburgh", "5421", "2011/04/25", "$320,800"],
     ["Garrett Winters", "Accountant", "Tokyo", "8422", "2011/07/25", "$170,750"],
     ["Ashton Cox", "Junior Technical Author", "San Francisco", "1562", "2009/01/12", "$86,000"],
     ["Cedric Kelly", "Senior Javascript Developer", "Edinburgh", "6224", "2012/03/29", "$433,060"],
     ["Airi Satou", "Accountant", "Tokyo", "5407", "2008/11/28", "$162,700"]
];

$(document).ready(function () {
    $("#gvDetails").dataTable({
        data: dataSet,
        //bJQueryUI: true
        //,sPaginationType: "full_numbers"
    });

1 个答案:

答案 0 :(得分:0)

请记住导入JqueryDataTables。那是工作:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<script type="text/javascript" src="https://cdn.datatables.net/1.10.10/js/jquery.dataTables.min.js"></script>

<强> HTML

<table id="gvDetails" class="display DataTable" cellspacing="0" width="100%">
    <thead>
        <tr>
            <th>Name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
         </tr>
    </thead>

    <tbody>

    </tbody>
</table>

<强> JS

var dataSet = [
 ["Tiger Nixon", "System Architect", "Edinburgh", "5421", "2011/04/25", "$320,800"],
 ["Garrett Winters", "Accountant", "Tokyo", "8422", "2011/07/25", "$170,750"],
 ["Ashton Cox", "Junior Technical Author", "San Francisco", "1562", "2009/01/12", "$86,000"],
 ["Cedric Kelly", "Senior Javascript Developer", "Edinburgh", "6224", "2012/03/29", "$433,060"],
 ["Airi Satou", "Accountant", "Tokyo", "5407", "2008/11/28", "$162,700"]
];

$(document).ready(function () {
    $("#gvDetails").dataTable({
        data: dataSet,
        //bJQueryUI: true
        //,sPaginationType: "full_numbers"
    });
});

结果: https://jsfiddle.net/cmedina/7kfmyw6x/53/