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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Gridfield Custom Filter


Go to End


1050 Views

Avatar
Scott Farmer

Community Member, 49 Posts

5 February 2015 at 3:24pm

For a field I'm displaying in the gridfield, it's value is a int and using $summary_fields to display the matching title value for each ID. i.e.
private static $summary_fields = array(
'PickUpLocationTitle' => 'PickUpLocation'
);

function getPickUpLocationTitle() {
if ($Pages = VehicleLocations::get()->byID($this->PickUpLocation)) {
return $Pages->Title;
} else {
return $this->PickUpLocation;
}
}

This works fine, but the issue is when filtering on the fields. As the value is a int and not a text varchar, search brings up no results.

Is it possible to either add a custom filter with a drop down field of locations to search on or translate the location title to the int id?

Thanks
Scott