0 follower

Interface Yiisoft\Yii\DataView\GridView\Column\ColumnRendererInterface

Implemented byYiisoft\Yii\DataView\GridView\Column\ActionColumnRenderer, Yiisoft\Yii\DataView\GridView\Column\CheckboxColumnRenderer, Yiisoft\Yii\DataView\GridView\Column\FilterableColumnRendererInterface, Yiisoft\Yii\DataView\GridView\Column\RadioColumnRenderer, Yiisoft\Yii\DataView\GridView\Column\SerialColumnRenderer

Interface for column renderers that handle the visual presentation of grid columns.

Column renderers are responsible for transforming column definitions into HTML output by configuring cells for different parts of the column (container, header, body, footer). Each renderer works with a specific column type and handles its unique rendering requirements.

Features:

  • Column container configuration
  • Header cell rendering with optional visibility
  • Data cell rendering with row context
  • Footer cell rendering
  • Context-aware rendering decisions

Example implementation: `php class CustomColumnRenderer implements ColumnRendererInterface {

public function renderColumn(ColumnInterface $column, Cell $cell, GlobalContext $context): Cell
{
    return $cell->addClass('custom-column');
}

public function renderHeader(ColumnInterface $column, Cell $cell, HeaderContext $context): ?Cell
{
    return $cell->content('Custom Header');
}

public function renderBody(ColumnInterface $column, Cell $cell, DataContext $context): Cell
{
    return $cell->content($context->data['value']);
}

public function renderFooter(ColumnInterface $column, Cell $cell, GlobalContext $context): Cell
{
    return $cell->content('Total');
}

} `

See also:

Method Details

Hide inherited methods

renderBody() public abstract method

Configures a data row cell.

This method is called for each row in the grid to render the column's data cell.

public abstract Yiisoft\Yii\DataView\GridView\Column\Base\Cell renderBody ( Yiisoft\Yii\DataView\GridView\Column\ColumnInterface $column, Yiisoft\Yii\DataView\GridView\Column\Base\Cell $cell, Yiisoft\Yii\DataView\GridView\Column\Base\DataContext $context )
$column Yiisoft\Yii\DataView\GridView\Column\ColumnInterface

The column definition to render.

$cell Yiisoft\Yii\DataView\GridView\Column\Base\Cell

The body cell to configure.

$context Yiisoft\Yii\DataView\GridView\Column\Base\DataContext

Row-specific data and rendering context.

return Yiisoft\Yii\DataView\GridView\Column\Base\Cell

The configured data cell.

                public function renderBody(ColumnInterface $column, Cell $cell, DataContext $context): Cell;

            
renderColumn() public abstract method

Configures the column container cell.

This method is called once per column to set up the container that will hold all the column's cells.

public abstract Yiisoft\Yii\DataView\GridView\Column\Base\Cell renderColumn ( Yiisoft\Yii\DataView\GridView\Column\ColumnInterface $column, Yiisoft\Yii\DataView\GridView\Column\Base\Cell $cell, Yiisoft\Yii\DataView\GridView\Column\Base\GlobalContext $context )
$column Yiisoft\Yii\DataView\GridView\Column\ColumnInterface

The column definition to render.

$cell Yiisoft\Yii\DataView\GridView\Column\Base\Cell

The cell container to configure.

$context Yiisoft\Yii\DataView\GridView\Column\Base\GlobalContext

Global grid rendering context.

return Yiisoft\Yii\DataView\GridView\Column\Base\Cell

The configured column container cell.

                public function renderColumn(ColumnInterface $column, Cell $cell, GlobalContext $context): Cell;

            
renderFooter() public abstract method

Configures the column footer cell.

public abstract Yiisoft\Yii\DataView\GridView\Column\Base\Cell renderFooter ( Yiisoft\Yii\DataView\GridView\Column\ColumnInterface $column, Yiisoft\Yii\DataView\GridView\Column\Base\Cell $cell, Yiisoft\Yii\DataView\GridView\Column\Base\GlobalContext $context )
$column Yiisoft\Yii\DataView\GridView\Column\ColumnInterface

The column definition to render.

$cell Yiisoft\Yii\DataView\GridView\Column\Base\Cell

The footer cell to configure.

$context Yiisoft\Yii\DataView\GridView\Column\Base\GlobalContext

Global grid rendering context.

return Yiisoft\Yii\DataView\GridView\Column\Base\Cell

The configured footer cell.

                public function renderFooter(ColumnInterface $column, Cell $cell, GlobalContext $context): Cell;

            
renderHeader() public abstract method

Configures the column header cell.

public abstract Yiisoft\Yii\DataView\GridView\Column\Base\Cell|null renderHeader ( Yiisoft\Yii\DataView\GridView\Column\ColumnInterface $column, Yiisoft\Yii\DataView\GridView\Column\Base\Cell $cell, Yiisoft\Yii\DataView\GridView\Column\Base\GlobalContext $context )
$column Yiisoft\Yii\DataView\GridView\Column\ColumnInterface

The column definition to render.

$cell Yiisoft\Yii\DataView\GridView\Column\Base\Cell

The header cell to configure.

$context Yiisoft\Yii\DataView\GridView\Column\Base\GlobalContext

Global grid rendering context.

return Yiisoft\Yii\DataView\GridView\Column\Base\Cell|null

The configured header cell, or null if no header should be shown.

                public function renderHeader(ColumnInterface $column, Cell $cell, GlobalContext $context): ?Cell;