简体   繁体   中英

Datatables Multi Column Sorting

Is there anyway with DataTables to preform a multi-column sort where the secondary column is always sorted DSC irrespective to what sorting direction the primary column is sorted.

{
   targets: [ 0 ],
   orderData: [ 0, 12 ] //Column 12 needs to always be sorted DSC
}

You could just use orderFixed for sorting like this

$(document).ready( function () {
var table = $('#example').DataTable({
  columnDefs: [{
    targets: [ 0 ],
    orderData: [ 0, 12 ]
  }],

  orderFixed: [[ 12, "desc" ]]

  });
} );

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM