From fda6fe8ade9c8a8472ee1a17b727bf36cd8e3a56 Mon Sep 17 00:00:00 2001 From: Mojmir Fendek Date: Tue, 20 Mar 2018 13:46:44 +1300 Subject: [PATCH] Added missing canFilterAnyColumns function. --- src/Form/GridField/RichFilterHeader.php | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/Form/GridField/RichFilterHeader.php b/src/Form/GridField/RichFilterHeader.php index ff16206..4251bbb 100755 --- a/src/Form/GridField/RichFilterHeader.php +++ b/src/Form/GridField/RichFilterHeader.php @@ -481,6 +481,36 @@ public function getFilterField($field) return null; } + /** + * Returns whether this {@link GridField} has any columns to sort on at all. + * + * @param GridField $gridField + * @return boolean + */ + public function canFilterAnyColumns($gridField) + { + $list = $gridField->getList(); + + if (!$this->checkDataType($list)) { + return false; + } + + $columns = $gridField->getColumns(); + foreach ($columns as $name) { + $metadata = $gridField->getColumnMetadata($name); + $title = $metadata['title']; + + $fieldConfig = $this->findFieldConfig($name); + $name = (!empty($fieldConfig['title'])) ? $fieldConfig['title'] : $name; + + if ($title && !empty($fieldConfig) && ($list->canFilterBy($name) || $this->hasFilterMethod($name))) { + return true; + } + } + + return false; + } + /** * @param GridField $gridField * @param SS_List $dataList