Update responsivePriority on sort
Update responsivePriority on sort

Hi,
Is there a way I can dynamically set the responsive priority on a sorted column?
Thanks
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi @mattct ,
You can do that by adding classes to the column's headers - see
responsive.rebuild()
which contains an example doing that.Cheers,
Colin
@colin
Apologies for the late reply, but I've finally got around to looking at this.
I'm not sure class based is going to provide the right solution. I was hoping to be able to update responsive priority in column defs based on the sort/order, or set/remove data-priority attributes for each sort event.
This kind of works, but I'm finding issues with applying this ordering does not update any previous responsive settings. On initial page load it may be that column 4 is prioritised. If I trigger the above to sort on column 9, the priority will be set to column 4 and the 9.
Hi @mattct ,
One solution perhaps would be to have no priorities on the HTML, and just add them programmatically as you are above in the
initComplete
. That way they would also be added in a consistent way.Cheers,
Colin
Hi @colin ,
Thanks for the nudge in the 'right' direction.
I've tried this on
drawCallback
, which seems to achieve the desired behaviour. How does this look rather than oninitComplete
?I think I'm right in assuming I can remove the above
$('#dt_basic').on('order.dt', function (){...
function asdrawCallback
enables the same thing?Thanks
Hi @mattct ,
drawCallback
is called every time the table is drawn (paged, ordered or searched),initComplete
is only called once when the data is loaded.So, your code above looks right for your issue.
Yep. The
order.dt
wouldn't have an effect if you paged or searched, so thedrawCallback
is the correct place to go there.Cheers,
Colin