src/Forms/GridField/GridFieldPrintButton.php
public function generatePrintData(GridField $gridField)
    {
        $printColumns = $this->getPrintColumnsForGridField($gridField);

        $header = null;

        if ($this->printHasHeader) {
            $header = new ArrayList();

            foreach ($printColumns as $field => $label) {
                $header->push(new ArrayData(array(
                    "CellString" => $label,
                )));
            }
        }

        $items = $gridField->getManipulatedList();
        $itemRows = new ArrayList();

        /** @var DataObject $item */
        foreach ($items->limit(null) as $item) {
            $itemRow = new ArrayList();

            foreach ($printColumns as $field => $label) {
                $value = $gridField->getDataFieldValue($item, $field);

                $itemRow->push(new ArrayData(array(
                    "CellString" => $value,
                )));
            }

            $itemRows->push(new ArrayData(array(
                "ItemRow" => $itemRow
            )));
            if ($item->hasMethod('destroy')) {
                $item->destroy();
            }
        }

        $ret = new ArrayData(array(
            "Title" => $this->getTitle($gridField),
            "Header" => $header,
            "ItemRows" => $itemRows,
            "Datetime" => DBDatetime::now(),
            "Member" => Security::getCurrentUser(),
        ));

        return $ret;
    }
public function generatePrintData(GridField $gridField)
    {
        $printColumns = $this->getPrintColumnsForGridField($gridField);

        $header = null;

        if ($this->printHasHeader) {
            $header = new ArrayList();

            foreach ($printColumns as $field => $label) {
                $header->push(new ArrayData(array(
                    "CellString" => $label,
                )));
            }
        }

        $items = $gridField->getManipulatedList();
        $itemRows = new ArrayList();

        /** @var DataObject $item */
        foreach ($items->limit(null) as $item) {
            $itemRow = new ArrayList();

            foreach ($printColumns as $field => $label) {
                $value = $gridField->getDataFieldValue($item, $field);

                $itemRow->push(new ArrayData(array(
                    "CellString" => $value,
                )));
            }

            $itemRows->push(new ArrayData(array(
                "ItemRow" => $itemRow
            )));
            if ($item->hasMethod('destroy')) {
                $item->destroy();
            }
        }

        $ret = new ArrayData(array(
            "Title" => $this->getTitle($gridField),
            "Header" => $header,
            "ItemRows" => $itemRows,
            "Datetime" => DBDatetime::now(),
            "Member" => Security::getCurrentUser(),
        ));

        return $ret;
    }
public function generatePrintData ( GridField $ gridField ) { $ printColumns = $ this -> getPrintColumnsForGridField ( $ gridField ) ; $ header = null ; if ( $ this -> printHasHeader ) { $ header = new ArrayList ( ) ; foreach ( $ printColumns as $ field => $ label ) { $ header -> push ( new ArrayData ( array ( "CellString" => $ label , ) ) ) ; } } $ items = $ gridField -> getManipulatedList ( ) ; $ itemRows = new ArrayList ( ) ; /** @var DataObject $item */ foreach ( $ items -> limit ( null ) as $ item ) { $ itemRow = new ArrayList ( ) ; foreach ( $ printColumns as $ field => $ label ) { $ value = $ gridField -> getDataFieldValue ( $ item , $ field ) ; $ itemRow -> push ( new ArrayData ( array ( "CellString" => $ value , ) ) ) ; } $ itemRows -> push ( new ArrayData ( array ( "ItemRow" => $ itemRow ) ) ) ; if ( $ item -> hasMethod ( 'destroy' ) ) { $ item -> destroy ( ) ; } } $ ret = new ArrayData ( array ( "Title" => $ this -> getTitle ( $ gridField ) , "Header" => $ header , "ItemRows" => $ itemRows , "Datetime" => DBDatetime :: now ( ) , "Member" => Security :: getCurrentUser ( ) , ) ) ; return $ ret ; }
Export core.

@param GridField $gridField
@return ArrayData
Export core .