UndefinedOffset / SortableGridField

Adds drag and drop functionality to Silverstripe's GridField
BSD 3-Clause "New" or "Revised" License
93 stars 62 forks source link

Drag and Drop Checkbox can't be selected #90

Closed vixen1975 closed 8 years ago

vixen1975 commented 8 years ago

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

UndefinedOffset commented 8 years ago

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.

vixen1975 commented 8 years ago

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.

vixen1975 commented 8 years ago

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!

UndefinedOffset commented 8 years ago

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.