From 25c180929c90a737db9ca621d589a5c3f2f93cb5 Mon Sep 17 00:00:00 2001 From: Ed Chipman Date: Thu, 22 Nov 2012 19:42:25 -0400 Subject: [PATCH] Added section about migrating from DOM issue 16 --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index f13aee7..5456f10 100644 --- a/README.md +++ b/README.md @@ -31,5 +31,13 @@ $myGridConfig->addComponent(new GridFieldSortableRows('{Column to store sort}')) To move an item to another page drag the row over the respective page button and release. +## Migrating from SilverStripe 2.4 and Data Object Manager's SortableDataObject +SortableGridField is not the same as SortableDataObject, since it is only a component of GridField it does not have the ability to catch the object when it is saved for the first time. So SortableGridField uses 1 as the first sort index because 0 is the default for an integer field/column in the database. For migrations from 2.4 with SortableDataObject you need to setup your DataObject based on the instructions above however you must name your sort column "SortOrder" to maintain your sort indexes defined by SortableDataObject. Then you need to run the following query on the table containing your sort field, for many_many relationships this will be something like {RelationshipClass}_{RelationshipName}. This query will maintain your sort order from SortableDataObject but increment the index by 1 giving it a starting number of 1. + +```sql +UPDATE YourTable SET SortOrder=SortOrder+1; +``` + + ## @TODO * Optimize re-ordering of a has_many relationship when sorting on a single page