Skip to content

Commit

Permalink
Added missing canFilterAnyColumns function.
Browse files Browse the repository at this point in the history
  • Loading branch information
mfendeksilverstripe committed Mar 20, 2018
1 parent 1c115a2 commit fda6fe8
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/Form/GridField/RichFilterHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fda6fe8

Please sign in to comment.