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

setColumnFunction() public method

Sets the column function to be executed for every row
public setColumnFunction ( mixed $function, mixed $arguments = null, mixed $columns, boolean $overwrite = true )
$function mixed The function to execute.
$arguments mixed The arguments to pass to the function.
$columns mixed The column wherein the result will be printed.
$overwrite boolean Should the original value be overwritten.
    public function setColumnFunction($function, $arguments = null, $columns, $overwrite = true)
    {
        // call the parent
        parent::setColumnFunction($function, $arguments, $columns, $overwrite);
        // redefine columns
        $columns = (array) $columns;
        $attributes = null;
        // based on the function we should prepopulate the attributes array
        switch ($function) {
            // timeAgo
            case array('DataGridFunctions', 'getTimeAgo'):
                $attributes = array('class' => 'date');
                $headerAttributes = array('class' => 'date');
                break;
        }
        // add attributes if they are given
        if (!empty($attributes)) {
            // loop and set attributes
            foreach ($columns as $column) {
                $this->setColumnAttributes($column, $attributes);
            }
        }
        // add attributes if they are given
        if (!empty($headerAttributes)) {
            // loop and set attributes
            foreach ($columns as $column) {
                $this->setColumnHeaderAttributes($column, $attributes);
            }
        }
    }