UndefinedOffset/SortableGridField

Drag and Drop Checkbox can't be selected

Closed this issue · 4 comments

I have a dataobject connected to a page and I can not make the checkbox select to allow drag and drop in the CMS.

The Dataobject has a field called 'SortOrder' (int), the page it is on has:

public function getCMSFields(){ $fields = parent::getCMSFields(); $conf=GridFieldConfig_RelationEditor::create(10); $conf->addComponent(new GridFieldSortableRows('SortOrder')); $gridField = new GridField("Staff Members", "Staff Members", $this->StaffMembers(), $conf); $fields->addFieldToTab("Root.StaffMembers", $gridField); $fields->removeByName('ContentPanels'); return $fields; }

Other pages in the site work no problems, just this one does not seem to work. I can't see any errors anywhere. I have tried adding a new field for the sort with a different name, and it also does not work. Do you have any ideas on what could be causing this?

Silverstripe 3.2, Sortable Grid Field dev-master downloaded via composer

What type of relationship are you managing your data object on is it a has_many or a many_many? If it's a many_many your sort order column must be in a many_many_extraFields declaration rather than the object being managed.

It is just a has_many. This is what I just can't get, this page and the data object are so simple. I have way more complex pages with data objects working just fine.

I downloaded the module again and also updated the CMS to 3.2.3 (only just handed the site over to the client, so don't want to update to 3.3 as it looks a little different), but no luck.

I'm having a brain-dead patch... There was a space in the name of the gridfield.

This:
$gridField = new GridField("Staff Members", "Staff Members", $this->StaffMembers(), $conf);

should be
$gridField = new GridField("StaffMembers", "Staff Members", $this->StaffMembers(), $conf);

Thanks for looking though!

Haha all good been there many times myself glad I could help even if it wasn't the end solution ;). As a tip there is a way to set the relationship name without the GridField's name matching. See the "Overriding the default relationship name" section in the read me.