Kyslik / column-sortable

Package for handling column sorting in Laravel 5/6/7/8
MIT License
644 stars 105 forks source link

Making the entire TH sortable #216

Closed stefanofinetti closed 1 year ago

stefanofinetti commented 1 year ago

Hello I was wondering if there is any chance to make the entire th clickable and sortable. At the moment using @sortablelink it renders clickable only the column name (and/or the icons). The empty space in the th is not clickable, and in mobile situations having to click with finger on the precise text could be a challenge for the user, whilst an entire clickable th would be way easier. Is there a way to make this possible?

Healyhatman commented 1 year ago

This is not a Vue or javascript solution, it's a blade solution that just renders a link. If you want to do that, you should bind a listener to the th element yourself to action the URL in the sortable link.

For example you could add a has-sortable-links class to your table, and in jQuery do something along the lines of

$(document).on('click', '.has-sortable-links th', function(e) {
   e.preventDefault();
   if ($(this).find('a')) {
    // do something
   }

OR you could do something much nicer than that. Just a gross example.