M
M
Mikha Pankratov2015-04-08 16:19:41
Yii
Mikha Pankratov, 2015-04-08 16:19:41

Yii2 How to do manual sorting - without any hassle?

Good afternoon,
So the situation is this, I upload a lot of pictures, I brought it out. But now I want to manually change the position of the photo queue, I think to change the timestamp of the addition and output accordingly.
But the problem is how to make it pleasant for the user?
Maybe there are some solutions already on this topic?
Or can you share yours? Many thanks in advance.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
LAV45, 2015-04-10
@frmax

https://github.com/himiklab/yii2-sortable-grid-vie...
In the controller, the ActiveDataProvider will need to disable pagination and sort

$dataProvider = new ActiveDataProvider([
            'query' => Images::find()
                ->orderBy(['sort_order' => SORT_ASC]),
            'pagination' => false,
            'sort' => false,
        ]);

In view, you can simply replace the namespace of the GridView class
use himiklab\sortablegrid\SortableGridView as GridView;

echo GridView::widget([
    'dataProvider' => $dataProvider,
    'columns' => [
        /* твои колонки */
    ],
]);

F
FanatPHP, 2015-04-08
@FanatPHP

ничего менять не надо.
дата добавления - это дата добавления, она нужна сама по себе
тем более что таймстамп будет у кучи фоток одинаковый.
Надо добавить отдельное поле для сортировки
Решений миллион.

Дмитрий Петрик, 2015-04-08
@Flexo

Может с помощью javascript? Например так

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question