Adding fields (Select or responsive) breaks sorting

Issue #35 closed
Robrecht Colson created an issue

Hey,

I love the package you made, but recently ran into an issue. I have two extra fields, defined client-side, to add a checkbox and to make the DT responsive. This breaks sorting however, as the two additional fields are not defined in columns on my view.

Do you have any idea if there's something I can do to resolve this on my end?

Many thanks in advance, Robrecht

Comments (3)

  1. Maciej Wisniowski repo owner

    Hard to say not seeing the code but in general if you want to add some columns that shouldn't be used for sorting then you can just add blank values for these in columns definition:

    columns = ['col1', 'col2', '', '', 'col3']
    

    and on the frontent side in the datatables definition just set these columns as not orderable, eg:

    $('#example').dataTable( {
      "columnDefs": [ {
          "targets": [2, 3],
          "orderable": false
        } ]
    } );
    
  2. Log in to comment