Hi There
I would like my gridfield to list only results that match a value of a particular field eg if fieldvalue is <= some number only show these records?
i have looked around but can't find a solid answer to this can anyone help please?
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
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.
Hi There
I would like my gridfield to list only results that match a value of a particular field eg if fieldvalue is <= some number only show these records?
i have looked around but can't find a solid answer to this can anyone help please?
Would you mind sharing more details, code?
Can give more detail
there are 3 classes involved the firs is Client, in the client class there are 2 has_many relationships Quote and Archive.
These Display in tabs within the client.
Currently when you view the quote tab at present it lists all records and same for the archive tab
What i would like to do is when you view the quote tab is have it list only the quotes with a particular statusID, and the same for the archive tab when viewed.
both of these relationships are shown with gridfield and i do not want to delete any quotes as the archive gets in formation from the quote.
I have looked at using something in the gridfield config, also i have explored GridFieldConfig_RelationEditor to automatically detach any records with a particular statusID.
hope this helps and makes sense
Hi voodoochile
Below is sample gallery page which i created
class GalleryPage extends Page {
private static $has_many = array(
'GalleryImages' => 'GalleryImage',
);
//private static $icon = GALLERY_ICON_PATH;
public function getCMSFields(){
$fields = parent::getCMSFields();
$gridFieldConfig = GridFieldConfig_RecordEditor::create();
$gridfield = new GridField("GalleryImages", "Gallery Images", $this->GalleryImages()->filter(array(
'Title' => 'Sam'
))->sort("SortOrder"), $gridFieldConfig);
$fields->addFieldToTab('Root.GalleryImages', $gridfield);
return $fields;
}
//*/
}
note
------
you can filter record as below, for demo purpose , i used $this->GalleryImages()->filter(array( 'Title' => 'Sam'))->sort("SortOrder")
$gridfield = new GridField("GalleryImages", "Gallery Images", $this->GalleryImages()->filter(array(
'Title' => 'Sam'
))->sort("SortOrder"), $gridFieldConfig);
Hi Thomas
Thanks for the prompt reply, This worked a treat it does exactly what i was trying to achieve.
It was the
->filter(array('Title'=>'sam'))
bit that i was missing.