2016-06-07 66 views
0

我在jQuery中使用數據表但不工作。我可以搭把手。這是劇本。謝謝! #userList是一個div,它包含一個表格條帶的表格 - 精簡的order-columns表格。謝謝!

$('#userList').DataTable({ 
    sortable: true, 
    processing: true, 
    serverSide: true, 
    ajax: { 
     url: 'include/dades_customers.php', 
     type: 'POST' 
    }, 
    columns: [ 
     {"data": "CustName"}, 
     {"data": "Address1"}, 
     {"data": "Address2"}, 
     {"data": "City"}, 
     {"data": "PostCode"}, 
     {"data": "State"}, 
     {"data": "Country"}, 
     {"data": "Phone"}, 
     {"data": "Fax"}, 
     {"data": "Web"} 
    ], 
    lengthMenu: [ 2, 5, 10, 25, 50, 75, 100 ], 
    //dom: '<"H"fi>rt<"F"lp><"clear">' 

    dom: '<"top"fiB><"content"rt><"footer"lp><"clear">', 
    buttons: [ 'colvis' ] 

    /*footerCallback: function(tfoot, data, start, end, display) { 
     var api = this.api(); 
     $(api.column(5).footer()).html(
      api.column(5).data().reduce(function (a, b) { 
       return a + b; 
      }, 0) 
     ); 
    } 
    */ 
}); 
+0

您是否包含所有文件?還jQuery的? – Mardzis

+0

是的!這包括 –

+1

如果沒有定義,你可能沒有添加適當的插件。 –

回答

2

要使用DataTable在page.Please頂部添加下列引用注意順序事項:

<link href="https://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css" rel="stylesheet" /> 
<script src="//code.jquery.com/jquery-1.12.3.min.js"></script> 
<script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script> 
1

我覺得現在的問題是,你說:

#userListdiv

我認爲#userList不能是div標記。它必須是table標記的ID。

相關問題