Source of file SectionedGridField.php
Size: 1,688 Bytes - Last Modified: 2021-12-23T10:55:59+00:00
/var/www/docs.ssmods.com/process/src/src/SectionedGridField.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 | <?php namespace Ucenna\SectionedGridField; use SilverStripe\Forms\GridField\GridField; use SilverStripe\Forms\GridField\GridFieldConfig; use SilverStripe\Forms\GridField\GridFieldConfig_RecordEditor; use SilverStripe\View\HTML; use SilverStripe\ORM\SS_List; /** * SectionedGridField */ class SectionedGridField extends GridField { /** * @param int $total * @param int $index * @param DataObject $record * @param array $attributes * @param string $content * * @return string * * added functionality to support appending content before or after a row */ protected function newRow($total, $index, $record, $attributes, $content) { $beforeRow = $afterRow = ''; foreach ($this->getComponents() as $item) { if ($item instanceof GridField_RowProvider) { $griditem = $this->getList()[$index]; $mycontent = $item->getRowHTMLFragments($this, $griditem, $index); if(array_key_exists('before_row', $mycontent)) { $beforeRow .= $mycontent['before_row']; } if(array_key_exists('after_row', $mycontent)) { $afterRow .= $mycontent['after_row']; } } } $row = HTML::createTag( 'tr', $attributes, $content ); $allRows = $beforeRow.$row.$afterRow; return $allRows; } /** * Disabled the base functionality for getManipulatedList * because it's incompatible with GridFieldSubGrid */ public function getManipulatedList() { return $this->getList(); } } |