Open rubenheymans opened 9 years ago
There are certain conditions in order to SortableColumn
to be visible:
access
closure is specified, it should return true
meaning current user have permissions to sort.scope
, according filter should be applied in GridView
, otherwise we are dealing with mix of models from different scopes and sorting doesn't make sense.sortableCondition
, the opposite filter (not sortable) should not be applied. For example, if you set filter to show deleted models, it doesn't make sense to sort them too since they all have sort = 0
.sortableAttribute
(ascending). You can append sort?=position
to applied filter.In your case seems like you missed to add sort to getting models query.
It's a bit unclear from documentation, I will add these details into README later.
Also you should rename <div class="question-index" id="question-sortable">
according to your model meaning, it's just an example. For example post-index
and post-sortable
.
I'll consider adding an option to always show SortableColumn
(except case when permissions check was failed).
@rubenheymans Did you solve the problem?
I did not solve it because I'm using another sortable behavior. This one looks better but I don't have time now to implement it.
Hmm, got same problem , and I couldnt solve yet
I solved this by explicitly setting the ActiveDataProvider property 'defaultSort', like this (in controller):
$dataProvider->sort = [ 'defaultOrder'=>['display_order'=>SORT_ASC] ];
I tried the most basic example, but I can't see any extra buttons in my Gridview
Behavior in model:
Index view: