addComponent(new GridFieldExportButton()); $this->addComponents([ new CommentsGridFieldSpamAction(), new CommentsGridFieldApproveAction(), ]); // Format column /** @var GridFieldDataColumns $columns */ $columns = $this->getComponentByType(GridFieldDataColumns::class); $columns->setFieldFormatting([ 'Parent.Title' => function ($value, &$item) { if ($link = $item->Link()) { return sprintf( '%s', Convert::raw2att($link), $item->obj('ParentTitle')->forTemplate() ); } else { return $item->obj('ParentTitle')->forTemplate(); } } ]); // Add bulk option $manager = BulkManager::create(null, false); $spamAction = SpamHandler::create()->setLabel(_t(__CLASS__ . '.SPAM', 'Spam')); $approveAction = ApproveHandler::create()->setLabel(_t(__CLASS__ . '.APPROVE', 'Approve')); $manager ->addBulkAction($spamAction) ->addBulkAction($approveAction); $this->addComponent($manager); } }