Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Adding Sort to Member Table


Go to End


1297 Views

Avatar
zenmonkey

Community Member, 545 Posts

19 February 2016 at 3:38am

I have a Page that displays a list of Members in a group, but I need to change the sort of the group members. I though the esiest way would be to add a relation editor to the pagetype with the sort order added via a Data Extension

Here is my extension on Group

class MyGroup extends DataExtension {
    static $many_many_extraFields = array(
        'Members' => array(
            'SortOrder' => "Int"
        )
    );
}

On the Page I have the following:
if($this->GroupID != 0 && Permission::check("APPLY_ROLES")) {
    $group = Group::get()->byID($this->GroupID);
    $fields->addFieldsToTab("Root.Members", array(
         GridField::create(
            "Members",
            "Members",
            $group->DirectMembers(),
            GridFieldConfig_RelationEditor::create()->addComponents(
                new GridFieldSortableRows('SortOrder')
            )
        )
    ));
}

When I try to sort the Members I get an error
Uncaught SS_DatabaseException: Couldn't run query:
UPDATE "" SET "SortOrder" = 1 WHERE "" = 12 AND "" = 18

I'm not sure why GridField isn't getting the Columns