2014-06-05 64 views

回答

0

HTML文件中數據表初始化的代碼。有一點必須記住初始化不在本地服務器上完成。該代碼必須在遠程服務器上運行。

$(document).ready(function() { 
var $dt = $('#example1').dataTable({ 
"bProcessing": true, 
     "bServerSide": true, 
     "bAutoWidth": false, 
     "pagingType": "full_numbers", 
     "sAjaxSource": "server.php", 
     "aaSorting": [[3, "desc"]], 
     "fnServerData": function(sUrl, aoData, fnCallback) { 
     $.ajax({ 
     "url": sUrl, 
       "data": aoData, 
       "success": fnCallback, 
       "dataType": "json", 
       "cache": false 
     }); 
     } 
}); 
     //$dt.fnDraw(); 

     $dt.columnFilter({sPlaceHolder: "head:before", 
       aoColumns: [ 
         null, 
         null, 
         null, 
         null, 
         null, 
         null, 
         null, 
         null, 
       { 
       type: "checkbox", 
         values: 
         [ 
         {value: '3', label: 'New'}, 
         {value: '0', label: 'Pending'}, 
         {value: '1', label: 'Active'}, 
         {value: '2', label: 'Inactive'}, 
         ] 
       }, 
         null, 
         null, 
         null, 
         null, 
         null, 
         null, 
         null, 
       ] 
     });