After save: position has wrong value
beatep opened this issue · 3 comments
Sorry, but I found another bug.
in behavior->beforeInsert the first value is 1 for the order column.
I had this in my grid (like 1, 2, 3, 4, 5), but after saving it was 0,1,2,3,4.
Could you reproduce this? I think it is because of this line:
$model->{$this->orderAttribute} = $order;
$order is the key, beginning with 0.
Very strange, btw: in a grid w/o sorting, the data-key value of an tr is the id of the model, like here:
In a sortable grid it is like this:
so data-sortable-id is the id of the model and data-key is the order column, I think?
data-key
isn't sortable plugin data. data-key
is ids of your models inside cycle of GridView.
and what about the position? I could fix this in the extension, but after composer update it's broken again.
it works from 0 (https://github.com/kotchuprik/yii2-sortable-widgets/blob/master/actions/Sorting.php#L21) right. it's big problem?
so data-sortable-id is the id of the model and data-key is the order column, I think?
is the id of the model if you are using ActiveDataProvider, but you are using ArrayDataProvider and 0, 1, 2, 3 is key of array with models.