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

[Solved] Searchable_fields sort?


Go to End


3 Posts   1253 Views

Avatar
Graphicator

Community Member, 62 Posts

31 January 2011 at 10:00pm

Overriding a textfield is pretty basic

	
static $searchable_fields = array(
		"Title" => array(
			 "field" => "TextField",
			 "filter" => "PartialMatchFilter",
			 "title" => 'Caller Name'
		)

In Order to override the design of a Dropdown field, I placed

		"Destinations.ID" => array(
			 "filter" => "ExactMatchFilter",
			 "title" => 'Destination'
		)

By removing the field in the array.
Is there a sort that I can place in the array?

Avatar
swaiba

Forum Moderator, 1899 Posts

1 February 2011 at 12:54am

Edited: 01/02/2011 12:54am

I don't know (and don't think so) - but would very much like this option too!

you might be able to hack it by overriding (in your ModelAdmin_CollectionController)

	function getSearchQuery($searchCriteria){
	$query = parent::getSearchQuery($searchCriteria);
	//modify $query here
	return $query;
}

alternative is to have the best sort defined in the dataobject...

	static $default_sort = 'Title ASC';

Avatar
Graphicator

Community Member, 62 Posts

1 February 2011 at 1:01am

Your alternative worked. Thank you!