The export columns need to be set in order for the csv generator to function properly.

Updating getReportField() in cms/code/report/Report.php like below will fix this issue

 

public function getReportField() {
// TODO Remove coupling with global state
$params = isset($_REQUEST[‘filters’]) ? $_REQUEST[‘filters’] : array();
$items = $this->sourceRecords($params, null, null);
$exportButton = new GridFieldExportButton(‘buttons-after-left’);

$gridFieldConfig = GridFieldConfig::create()->addComponents(
new GridFieldToolbarHeader(),
new GridFieldSortableHeader(),
new GridFieldDataColumns(),
new GridFieldPaginator(),
new GridFieldButtonRow(‘after’),
new GridFieldPrintButton(‘buttons-after-left’),
$exportButton
);
$gridField = new GridField(‘Report’,false, $items, $gridFieldConfig);
$columns = $gridField->getConfig()->getComponentByType(‘GridFieldDataColumns’);
$displayFields = array();
$fieldCasting = array();
$fieldFormatting = array();

// Parse the column information
foreach($this->columns() as $source => $info) {
if(is_string($info)) $info = array(‘title’ => $info);

if(isset($info[‘formatting’])) $fieldFormatting[$source] = $info[‘formatting’];
if(isset($info[‘csvFormatting’])) $csvFieldFormatting[$source] = $info[‘csvFormatting’];
if(isset($info[‘casting’])) $fieldCasting[$source] = $info[‘casting’];

if(isset($info[‘link’]) && $info[‘link’]) {
$fieldFormatting[$source] = function($value, &$item) {
return sprintf(
%s‘,
Controller::join_links(singleton(‘CMSPageEditController’)->Link(‘show’), $item->ID),
$value
);
};
}

$displayFields[$source] = isset($info[‘title’]) ? $info[‘title’] : $source;
}
$columns->setDisplayFields($displayFields);
$columns->setFieldCasting($fieldCasting);
$columns->setFieldFormatting($fieldFormatting);
$exportButton->setExportColumns($displayFields);
return $gridField;
}

 

Leave a Reply