''); } } /** * Which columns are handled by this component * * @param type $gridField * @return type */ public function getColumnsHandled($gridField) { return array('Actions'); } /** * Which GridField actions are this component handling * * @param GridField $gridField * @return array */ public function getActions($gridField) { return array('unlinkrelation'); } /** * * @param GridField $gridField * @param DataObject $record * @param string $columnName * @return string - the HTML for the column */ public function getColumnContent($gridField, $record, $columnName) { $field = Object::create('GridField_Action', $gridField, 'UnlinkRelation'.$record->ID, false, "unlinkrelation", array('RecordID' => $record->ID) ) ->setAttribute('title', _t('GridAction.UnlinkRelation', "Unlink")) ->setAttribute('data-icon', 'chain--minus') ->addExtraClass('gridfield-button-unlick'); return $field->Field(); } /** * Handle the actions and apply any changes to the GridField * * @param GridField $gridField * @param string $actionName * @param mixed $arguments * @param array $data - form data * @return void */ public function handleAction(GridField $gridField, $actionName, $arguments, $data) { $id = $arguments['RecordID']; $item = $gridField->getList()->byID($id); if(!$item) return; if($actionName == 'unlinkrelation') { $gridField->getList()->remove($item); } } }