column-sortable icon indicating copy to clipboard operation
column-sortable copied to clipboard

Overriding the direction parameter

Open khamyl opened this issue 3 years ago • 2 comments

If the direction toggle in anchors is not what you want, e.g. you needed to have two different buttons for ASC and DESC, you can override the direction in the link as follows:

<ul class="dropdown-menu pull-right">
    <li>@sortablelink('tag', 'Alphabetically [A-Z]', ['direction'=>'asc'])</li>
    <li>@sortablelink('tag', 'Reverse Alphabetically [Z-A]', ['direction'=>'desc'])</li>
    <li><a href="#">TBD: Most documents</a></li>
    <li><a href="#">TBD: Fewest documents</a></li>
    <li class="divider"></li>
    <li><a href="/tags">Reset (by Time Created)</a></li>
</ul>

khamyl avatar Jan 21 '22 20:01 khamyl

Fixes #187

robbielove avatar Feb 09 '22 14:02 robbielove

I tried this out (without using the session part) - I had a different use case - I wanted to override direction to provide a way to start with a page on the default sort column (I have it defined per model) and give it the opposite direction so that it naturally sorted the other way for the default sort field I found that I required these changes to your PR for it to work in my case https://github.com/Kyslik/column-sortable/commit/7568d72b55d74acc8611b0f2b587d96dd909fa81

We might need to find a way to allow the icon to be changed or remain as the default sort icon - as not everyone using the package will be passing direction for the reason you intend.

robbielove avatar Feb 09 '22 14:02 robbielove