Click on an orderable: false column header refresh the datatable for nothing

Click on an orderable: false column header refresh the datatable for nothing

PhilTractionPhilTraction Posts: 2Questions: 2Answers: 0

I found that adding data-dt-order="disable" to the <th> fix this, but is it normal?
I think it is since we upgraded to version 2.

Answers

  • kthorngrenkthorngren Posts: 21,790Questions: 26Answers: 5,042
    edited March 12

    I'm guessing you have complex headers like this example. I copied that example into this test case:
    https://live.datatables.net/kobezuqo/1/edit

    Using data-dt-order="disable" on the colspans you don't want to sort is probably best. It seems setting columns.orderable for these columns leads to some unexpected behavior. The test case has this:

      columnDefs: [
        {
          targets: [3, 4, 5],
          orderable: false
        }
      ]
    

    Clicking on any of the Contact or Direct th elements doesn't sort. However clicking on HR Info for the Office column does perform a sort but the sorting icon doesn't update. @allan can comment on the specific behavior.

    Kevin

  • allanallan Posts: 64,142Questions: 1Answers: 10,584 Site admin

    The sorting icon doesn't update for "HR info" as it is looking for sorting to be applied to all three columns that the header cell covers. But sorting can't be applied to the office column, thus the icon isn't updated. You'll notice that it does on "Position" though, since it covers the two columns which are sorted on.

    Interesting one... I think I'm happy with that behaviour for the moment, but I will consider options.

    Allan

Sign In or Register to comment.