使用datatable插件进行当前页面排序

时间:2021-06-17 20:31:11

I want to sort current page only using datatable plugin. Is there any way to do this?

我想只使用datatable插件对当前页面进行排序。有没有办法做到这一点?

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)"
        }       
    });

1 个解决方案

#1


0  

Bydefault Datatables provide sorting functionality. But if you can sorting for particular column for particular table, you can use this code.

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

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

Here [ 3, 'desc' ] means (0,1,2,3) fourth column in descending order, [ 0, 'asc' ] means first column in ascending order.

这里[3,'desc']按降序表示(0,1,2,3)第四列,[0,'asc']表示按升序排列的第一列。

#1


0  

Bydefault Datatables provide sorting functionality. But if you can sorting for particular column for particular table, you can use this code.

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

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

Here [ 3, 'desc' ] means (0,1,2,3) fourth column in descending order, [ 0, 'asc' ] means first column in ascending order.

这里[3,'desc']按降序表示(0,1,2,3)第四列,[0,'asc']表示按升序排列的第一列。