Backend\Core\Engine\DataGrid::addColumnAction PHP Method

addColumnAction() public method

Adds a new column with a custom action button
public addColumnAction ( string $name, string $label = null, string $value = null, string $url = null, string $title = null, array $anchorAttributes = null, string $image = null, integer $sequence = null )
$name string The name for the new column.
$label string The label for the column.
$value string The value for the column.
$url string The URL for the link inside the column.
$title string The title for the link inside the column.
$anchorAttributes array The attributes for the anchor inside the column.
$image string An URL to the image inside the column.
$sequence integer The sequence for the column.
    public function addColumnAction($name, $label = null, $value = null, $url = null, $title = null, $anchorAttributes = null, $image = null, $sequence = null)
    {
        // reserve var for attributes
        $attributes = '';
        $icon = $this->decideIcon($name);
        // no anchorAttributes set means we set the default class attribute for the anchor
        if (empty($anchorAttributes)) {
            $anchorAttributes['class'] = 'btn btn-default btn-xs';
        }
        // loop the attributes, build our attributes string
        foreach ($anchorAttributes as $attribute => $attributeValue) {
            $attributes .= ' ' . $attribute . '="' . $attributeValue . '"';
        }
        // rebuild value
        $value = '<a href="' . $url . '"' . $attributes . '>' . ($icon ? '<span class="fa ' . $icon . '"></span>&nbsp;' : '') . $value . '</a>';
        // add the column to the datagrid
        parent::addColumn($name, $label, $value, null, $title, $image, $sequence);
        // set column attributes
        $this->setColumnAttributes($name, array('class' => 'fork-data-grid-action action' . \SpoonFilter::toCamelCase($name), 'style' => 'width: 10%;'));
        // set header attributes
        $this->setColumnHeaderAttributes($name, array('class' => $name));
    }