This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
I did everything like it is written here in the doc: https://octobercms.com/docs/backend/reorder Page is rendered, Js and drag and drop features works, no exaptions, no errors, but records are not sorted the way they should.
As I see the controller is using nested trees and I had records already in DB with no values there for: nest_left, nest_right and sort_order.
I've tryed to manualy fill them but it's a hard manual work I don't want even to try anymore and I never succeed to fill them propaly by hand.
So to make it work I probably need to create one more button to rearrange the tree ? Any other ideas on what can be wrong ?
Well, sorting is working fine for me now, I did even manage to make sorting for model where sort_order is in pivot table. Ands it's pretty straight forward, if you need just sorting use only Sorting trait for nested use NestedTree.
If somebody will need to sort pivot field the clue will be to create a sorter field with name different from sort_order (did not worked if there is the same name).
So inside model you will have:
'categories' => [
'Acme\Demo\Models\Category',
'table' => 'acme_demo_product_category',
'order' => ['sorter'],
'pivot' => ['is_published','sorter'],
'pivotModel' => 'Acme\Demo\Models\ProdCatPivot'
],
Don't forget in relation_config to add sorting: view: list: ...... showSorting: true defaultSort: sorter
Columns.yaml will have sorter and sort_order as our category model also sortable by sort_order field and with sorter controller.
columns:
name:
label: Title
sortable: false
sort_order:
label: Title
sortable: true
sorter:
label: Sorter
select: sort_order
As a result the relation data is sorted in backend in a right way. I do not have a js drag and drop functionality in backend by I do need it mostly on frontend there I just wrote a little more code to do it.
Could be good to have a simple javascript to be able to drag and drop in backend too. I see it could be done via formwidget.
1-2 of 2