order.listener() with complex header
order.listener() with complex header

I'm trying to workout how to use order.listener()
with complex headers. Trying to set the listener to use only the icon for the Position th
in this test case:
https://live.datatables.net/kekazaxo/1/edit
Using this code:
let th = table.column(1).header(0);
$( th ).attr('data-dt-order', 'icon-only');
table.order.listener( $('span.dt-column-order', th), 1);
The listener is set properly but the dt-ordering-[asc|desc]
class is not applied and the sorting icon is not updated. Do I need to do something differently?
FYI, I was trying to provide an example in this thread.
Kevin
Replies
Excellent question Kevin! So the issue is that only a single column is being ordered on - the second parameter (
1
in this case). However, that header cell is looking for ordering to be done on both columns - so its indicator doesn't change.The solution would be to pass in the two columns to
order.listener()
, but unfortunately at the moment it doesn't allow that - it expects an integer only.As such, I've gone ahead and committed a change to allow this.
Please note that I've committed this to a 2.3 branch, where I've been doing some work recently. I did consider putting it on master (2.2), but in keeping with semver, the new feature goes on the next minor release.
I'm hoping it won't be too long before 2.3 sees the light of day!
Allan
I figured it was something like this. Thanks!
Kevin