mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Use columns from gridfield for export
This commit is contained in:
parent
a73f08bd88
commit
4c856c4377
@ -92,6 +92,25 @@ class GridFieldExportButton implements GridField_HTMLProvider, GridField_ActionP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the columns to export
|
||||||
|
*
|
||||||
|
* @param GridField $gridField
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function getExportColumnsForGridField(GridField $gridField) {
|
||||||
|
if($this->exportColumns) {
|
||||||
|
$exportColumns = $this->exportColumns;
|
||||||
|
} else if($dataCols = $gridField->getConfig()->getComponentByType('GridFieldDataColumns')) {
|
||||||
|
$exportColumns = $dataCols->getDisplayFields($gridField);
|
||||||
|
} else {
|
||||||
|
$exportColumns = singleton($gridField->getModelClass())->summaryFields();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $exportColumns;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate export fields for CSV.
|
* Generate export fields for CSV.
|
||||||
*
|
*
|
||||||
@ -100,9 +119,7 @@ class GridFieldExportButton implements GridField_HTMLProvider, GridField_ActionP
|
|||||||
*/
|
*/
|
||||||
public function generateExportFileData($gridField) {
|
public function generateExportFileData($gridField) {
|
||||||
$separator = $this->csvSeparator;
|
$separator = $this->csvSeparator;
|
||||||
$csvColumns = ($this->exportColumns)
|
$csvColumns = $this->getExportColumnsForGridField($gridField);
|
||||||
? $this->exportColumns
|
|
||||||
: singleton($gridField->getModelClass())->summaryFields();
|
|
||||||
$fileData = '';
|
$fileData = '';
|
||||||
|
|
||||||
if($this->csvHasHeader) {
|
if($this->csvHasHeader) {
|
||||||
|
Loading…
Reference in New Issue
Block a user