AngularJS Datatables sort on checked items

I am using anguarljs Lin Datatables Lin Datatables
The datatables work nice and search,sort works great, but there is a requirement to sort the datatable's on checked items.
For example , when user checks the checkbox and wants to sort on basis of checked items the sorting functionality doesn't work.
enter image description here
Can anyone please suggest how to sort using Lin datatables on basis of check-boxes.
The html code for checking the check-box state is

    <td><input id="{{content.fileName}}" type="checkbox"
value="{{content.fileName}}" ng-model="content.isChecked"
ng-click="toggleSelection(content)" /></td>

Answers 1

  • You should implement the small dom-checkbox plugin. It works with angular dataTables as well :

    $.fn.dataTable.ext.order['dom-checkbox'] = function  ( settings, col ) {
      return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
        return $('input', td).prop('checked') ? '1' : '0';

    Then set the # column to use dom-checkbox as orderDataType :

      .withOption('orderDataType', 'dom-checkbox'),

    have replicated your scenario here ->

Related Articles