Permalink
Browse files

Respect displayFields in GridFieldPrintButton

Provides more coherent and expected default behaviour
  • Loading branch information...
1 parent 703c10a commit 80feb8c0b4b581255315e0f99fe8a77385302ba7 @chillu chillu committed Jan 14, 2013
Showing with 8 additions and 3 deletions.
  1. +8 −3 forms/gridfield/GridFieldPrintButton.php
View
11 forms/gridfield/GridFieldPrintButton.php
@@ -91,9 +91,14 @@ public function handlePrint($gridField, $request = null) {
* Export core.
*/
public function generatePrintData($gridField) {
- $printColumns = ($this->printColumns)
- ? $this->printColumns
- : singleton($gridField->getModelClass())->summaryFields();
+ if($this->printColumns) {
+ $printColumns = $this->printColumns;
+ } else if($dataCols = $gridField->getConfig()->getComponentByType('GridFieldDataColumns')) {
+ $printColumns = $dataCols->getDisplayFields($gridField);
+ } else {
+ $printColumns = singleton($gridField->getModelClass())->summaryFields();
+ }
+
$header = null;
if($this->printHasHeader){
$header = new ArrayList();

0 comments on commit 80feb8c

Please sign in to comment.