2017-10-16 33 views
0

此代碼工作正常,但不更改任何導出按鈕不顯示。datatable tabletools csv不工作

我已經插在正確的位置的庫:

$this->document->add_css('jquery.datetimepicker.css'); 
    $this->document->add_css('dataTables.tableTools.min.css'); 
    $this->document->add_js('jquery.datetimepicker.js'); 
    $this->document->add_js('jquery.dataTables.min.js'); 
    $this->document->add_js('dataTables.tableTools.js'); 

這是我的代碼:

$(".table-dashboard").DataTable({ 
     "dom": "T<\'clear\'>lfrtip", 
     initComplete: function(){ 
      $(".scrollable-list").before($(".DTTT_container")); 
      $(".DTTT_container").css("margin-bottom", "-33px"); 
     }, 
     bFilter: false, 
     "aoColumnDefs": 
     [ 
      { 
       "bSortable": false, 
       "aTargets": [$(this).find("thead tr th").length - 1] 
      } 
     ], 
     "oTableTools": 
     {//  "sSwfPath": "'.base_url(SYSTEM_MEDIA . "swf/copy_csv_xls_pdf.swf").'", 
      "sSwfPath": "http://cdn.datatables.net/tabletools/2.2.2/swf/copy_csv_xls_pdf.swf", 
      "aButtons": 
      [ 
       { 
        "sExtends"  : "csv", 
        "sButtonText" : "Export CSV <i class=\'fa fa-file-excel-o\'></i>", 
        "sButtonClass" : "btn btn-primary" 
       } 
      ] 
     } 
    }); 

回答

0

I`ve通過自己的解決方案成立,我加入了一些這些庫,供人失蹤。

<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script> 
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/buttons/1.4.2/js/dataTables.buttons.min.js"></script> 
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css"> 
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.4.2/css/buttons.dataTables.min.css"> 
<script type="text/javascript" charset="utf8" src="//cdn.datatables.net/buttons/1.4.2/js/buttons.html5.min.js"></script> 
<script type="text/javascript" charset="utf8" src="//cdn.datatables.net/buttons/1.4.2/js/buttons.print.min.js"></script> 

腳本:

dom: 'Bfrtip', 
     initComplete: function(){ 
      $(".scrollable-list").before($(".DTTT_container")); 
      $(".DTTT_container").css("margin-bottom", "-33px"); 
     }, 
     bFilter: false, 
     "aoColumnDefs": 
     [ 
      { 
       "bSortable": false, 
       "aTargets": [$(this).find("thead tr th").length - 1] 
      } 
     ], 
     buttons: [ 
      { 
       extend: "csv", 
       text: "Export CSV", 
       className: "btn btn-primary" 
      } 
     ]   
相關問題