column-sortable
column-sortable copied to clipboard
Overriding the direction parameter
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>
Fixes #187
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.