mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #9173 from creative-commoners/pulls/4.3/column-content-for-print-csvs
FIX Use content generated by DataColumns component for print and csv export
This commit is contained in:
commit
05d5db43f3
@ -214,6 +214,9 @@ class GridFieldExportButton implements GridField_HTMLProvider, GridField_ActionP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var GridFieldDataColumns|null $gridFieldColumnsComponent */
|
||||||
|
$gridFieldColumnsComponent = $gridField->getConfig()->getComponentByType(GridFieldDataColumns::class);
|
||||||
|
|
||||||
/** @var DataObject $item */
|
/** @var DataObject $item */
|
||||||
foreach ($items->limit(null) as $item) {
|
foreach ($items->limit(null) as $item) {
|
||||||
if (!$item->hasMethod('canView') || $item->canView()) {
|
if (!$item->hasMethod('canView') || $item->canView()) {
|
||||||
@ -228,6 +231,10 @@ class GridFieldExportButton implements GridField_HTMLProvider, GridField_ActionP
|
|||||||
}
|
}
|
||||||
|
|
||||||
$value = $columnHeader($relObj);
|
$value = $columnHeader($relObj);
|
||||||
|
} elseif ($gridFieldColumnsComponent) {
|
||||||
|
$value = strip_tags(
|
||||||
|
$gridFieldColumnsComponent->getColumnContent($gridField, $item, $columnSource)
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$value = $gridField->getDataFieldValue($item, $columnSource);
|
$value = $gridField->getDataFieldValue($item, $columnSource);
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ class GridFieldPrintButton implements GridField_HTMLProvider, GridField_ActionPr
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @var GridFieldDataColumns $dataCols */
|
/** @var GridFieldDataColumns $dataCols */
|
||||||
$dataCols = $gridField->getConfig()->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldDataColumns');
|
$dataCols = $gridField->getConfig()->getComponentByType(GridFieldDataColumns::class);
|
||||||
if ($dataCols) {
|
if ($dataCols) {
|
||||||
return $dataCols->getDisplayFields($gridField);
|
return $dataCols->getDisplayFields($gridField);
|
||||||
}
|
}
|
||||||
@ -223,12 +223,17 @@ class GridFieldPrintButton implements GridField_HTMLProvider, GridField_ActionPr
|
|||||||
$items = $gridField->getManipulatedList();
|
$items = $gridField->getManipulatedList();
|
||||||
$itemRows = new ArrayList();
|
$itemRows = new ArrayList();
|
||||||
|
|
||||||
|
/** @var GridFieldDataColumns $gridFieldColumnsComponent */
|
||||||
|
$gridFieldColumnsComponent = $gridField->getConfig()->getComponentByType(GridFieldDataColumns::class);
|
||||||
|
|
||||||
/** @var DataObject $item */
|
/** @var DataObject $item */
|
||||||
foreach ($items->limit(null) as $item) {
|
foreach ($items->limit(null) as $item) {
|
||||||
$itemRow = new ArrayList();
|
$itemRow = new ArrayList();
|
||||||
|
|
||||||
foreach ($printColumns as $field => $label) {
|
foreach ($printColumns as $field => $label) {
|
||||||
$value = $gridField->getDataFieldValue($item, $field);
|
$value = $gridFieldColumnsComponent
|
||||||
|
? strip_tags($gridFieldColumnsComponent->getColumnContent($gridField, $item, $field))
|
||||||
|
: $gridField->getDataFieldValue($item, $field);
|
||||||
|
|
||||||
$itemRow->push(new ArrayData(array(
|
$itemRow->push(new ArrayData(array(
|
||||||
"CellString" => $value,
|
"CellString" => $value,
|
||||||
|
Loading…
Reference in New Issue
Block a user