on a website I have DO “Products” and “Categories” in a has_many relation. Now customer likes to have an additional “otherCategories” in a many_many relation to “Product”.
On “CategoriesProductHolderPage” Products should be ordered according to “sortOrder”, whereas on “otherCategoriesProductHolderPage” they should be ordered accordung to “otherSortOrder”.
Ordering should be accomplished by drag and drop in Gridfield (with SortableGridField module).
Is there a way to accomplish this? All examples of sorting many_many relations that I found so far refer to default sorting on ONE “sortOrder” ONLY.
Thanks for the answer, @Tim! I didn’t have the YAML Part of the solution.
When I added the YAML, I still had an error on ordering the Products in the Gridfield. @wmk gave me the hint to look for the error message in the network tab of developer tools (webdeveloper window). There I found reordering occured on the wrong column.
So I changed column name from “sortOrder” to “otherSortOrder” in DO “otherCategories” in public function getCMSFields() into:
$gfConfProdukte = GridFieldConfig_RelationEditor::create(20);
$gfConfProdukte->addComponent(new GridFieldSortableRows(‘otherSortOrder’));