2016-08-02 72 views
0

我想仅使用数据表插件来排序当前页面。有没有办法做到这一点?使用数据表插件的当前页面明智排序

的javascript ODE:

$('#announcementListing-data').DataTable({ 
     pageLength: 5, 
     "columnDefs": [ { 
     "targets" : 'no-sort', 
     "orderable": false, 
     "order": [] 
    }],  
     "language": { 
      "lengthMenu": "Display _MENU_ records per page", 
      "zeroRecords": "Nothing found - sorry", 
      "info": "_PAGE_ of _PAGES_", 
      "infoEmpty": "No records available", 
      "infoFiltered": "(filtered from _MAX_ total records)" 
     }  
    }); 
+0

检查此URL:http://stackoverflow.com/questions/27437983/how-to-sort-only-the-current-page-using-jquery-datatable –

回答

0

Bydefault数据表提供排序的功能。但是,如果您可以对特定表格的特定列进行排序,则可以使用此代码。以降序

$(document).ready(function() { 
    $('#example').DataTable({ 
     order: [[ 3, 'desc' ], [ 0, 'asc' ]] 
    }); 
}); 

这里[3, '降序']装置(0,1,2,3)第四列,[0, '递增']是指以升序第一列。