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.

Customising the CMS /

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

Gridfield sortable headers for has_one relationship


Go to End


3 Posts   1054 Views

Avatar
MattMan9

Community Member, 3 Posts

6 October 2014 at 1:48pm

I have a facility CMS page that displays in a GridField campus a facility is located at the name of the facility and the description/media associated with that facility.

A facility has_one campus and stores its own description and name.

it has three summary_fields: campus title, facility title, facility description

public static $db = array(
'Title' => 'Varchar',
'Description' => 'HTMLText'

);

static $has_one = array(
'Facilities' => 'FacilitiesHolder',
'Campus' => 'CampusPage'
);

static $has_many = array(
'Images' => 'Gallery'
);

static $many_many = array(
'Courses' => 'CourseCategoryPage',
);

public static $summary_fields = array(
'Campus.Title' => 'Campuses',
'Title' => 'Title',
'Description' => 'Description'
);

on the CMS side the gridfield is sortable by facility title and descirption but NOT campus I need a way to sort by campus as well.

Any suggestions would be greatly appreciated

Avatar
kinglozzer

Community Member, 187 Posts

7 October 2014 at 1:01am

Hi Matt,

Which version of SilverStripe are you using? This was added in 3.1.3, so if it’s not working then it’s probably a bug.

Loz

Avatar
MattMan9

Community Member, 3 Posts

7 October 2014 at 12:14pm

I'm using SS 3 but the site is being updated to SS 3.1 soon