Source of file Grid.php
Size: 1,294 Bytes - Last Modified: 2021-12-23T10:19:36+00:00
/var/www/docs.ssmods.com/process/src/code/Grid.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 | <?php namespace SaltedHerring; class Grid { public static function make($name, $label = '', $source, $sortable = true, $gridHeaderType = 'GridFieldConfig_RecordEditor') { /* GridFieldConfig_Base GridFieldConfig_RecordViewer GridFieldConfig_RecordEditor GridFieldConfig_RelationEditor */ if ($label == '') { $label = $name; } $grid = new \GridField($name, $label, $source); $config = $gridHeaderType::create(); $config->removeComponentsByType('GridFieldPaginator') ->addComponents( new \GridFieldPaginatorWithShowAll(30) ); if ($sortable) { $config->addComponents( $sortable = new \GridFieldOrderableRows('SortOrder') ); } $grid->setConfig($config); return $grid; } public static function makeEditable($name, $label = '', $source, $sortable = true, $fields = null) { $grid = self::make($name, $label, $source, $sortable); $config = $grid->getConfig(); $fieldEditor = new \GridFieldEditableColumns(); $btnInlineAdd = new \GridFieldAddNewInlineButton(); if (!empty($fields)) { $fieldEditor->setDisplayFields($fields); } $config->removeComponentsByType('GridFieldAddNewButton') ->addComponents( $fieldEditor, $btnInlineAdd ); return $grid; } } |