# GridColumn

> Represents a panel grid column with pre-rendered header and filter content and a per-row body-content callback.

[API reference](/docs/api/index.md) › [Yii3 Debug](/docs/extensions/yii3-debug/reference/index.md) › [Web](/docs/extensions/yii3-debug/reference/web/index.md) › GridColumn

| final readonly class | `Yii3\Debug\Web\GridColumn` |
| --- | --- |
| Implements | `Yiisoft\Yii\DataView\GridView\Column\ColumnInterface` |
| Source | [`src/Web/GridColumn.php`](https://github.com/yii3/debug/blob/main/src/Web/GridColumn.php#L18) |

Represents a panel grid column with pre-rendered header and filter content and a per-row body-content callback.

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-bodyClass"></span>`$bodyClass` readonly constructor | `string\|null` | Extra CSS class for the body cells only, or `null` for none. Default: `null`. | `GridColumn` |
| <span id="property-class"></span>`$class` readonly constructor | `string\|null` | CSS class shared by the header, filter, and body cells, or `null` for none. Default: `null`. | `GridColumn` |
| <span id="property-content"></span>`$content` readonly constructor | [`Closure`](https://www.php.net/manual/en/class.closure.php)`(Yii3\Debug\Web\TRow, Yiisoft\Yii\DataView\GridView\Column\Base\DataContext): string` | Builds the body cell content for one row. | `GridColumn` |
| <span id="property-encodeContent"></span>`$encodeContent` readonly constructor | `bool` | Whether the body content is plain text that the cell must encode. Default: `false`. | `GridColumn` |
| <span id="property-filter"></span>`$filter` readonly constructor | `string\|`[`Stringable`](https://www.php.net/manual/en/class.stringable.php)`\|null` | Filter cell content; `null` renders no filter cell at all, `''` renders an empty cell that keeps the column class. Default: `null`. | `GridColumn` |
| <span id="property-header"></span>`$header` readonly constructor | `string\|PHPForge\Debug\View\Grid\SortHeader` | Header cell HTML, already rendered and encoded by the caller, or the header cell of a sortable column. | `GridColumn` |
| <span id="property-headerClass"></span>`$headerClass` readonly constructor | `string\|null` | Extra CSS class for the header cell only, or `null` for none. Default: `null`. | `GridColumn` |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Creates a grid-column definition from a header, a row-content callback, and presentation options. | `GridColumn` |
| [`getRenderer()`](#method-getRenderer) | Returns the renderer GridView resolves this column through. | `GridColumn` |
| [`isVisible()`](#method-isVisible) | Returns whether the column renders. | `GridColumn` |

## Method details

### __construct() <span id="method-__construct"></span>

```php
public function __construct(string|PHPForge\Debug\View\Grid\SortHeader $header, Closure(Yii3\Debug\Web\TRow, Yiisoft\Yii\DataView\GridView\Column\Base\DataContext): string $content, string|Stringable|null $filter = null, bool $encodeContent = false, string|null $class = null, string|null $headerClass = null, string|null $bodyClass = null)
```

Creates a grid-column definition from a header, a row-content callback, and presentation options.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$header` | `string\|PHPForge\Debug\View\Grid\SortHeader` | Header cell HTML, already rendered and encoded by the caller, or the header cell of a sortable column. |
| `$content` | [`Closure`](https://www.php.net/manual/en/class.closure.php)`(Yii3\Debug\Web\TRow, Yiisoft\Yii\DataView\GridView\Column\Base\DataContext): string` | Builds the body cell content for one row. |
| `$filter` | `string\|`[`Stringable`](https://www.php.net/manual/en/class.stringable.php)`\|null` | Filter cell content; `null` renders no filter cell at all, `''` renders an empty cell that keeps the column class. |
| `$encodeContent` | `bool` | Whether the body content is plain text that the cell must encode. |
| `$class` | `string\|null` | CSS class shared by the header, filter, and body cells, or `null` for none. |
| `$headerClass` | `string\|null` | Extra CSS class for the header cell only, or `null` for none. |
| `$bodyClass` | `string\|null` | Extra CSS class for the body cells only, or `null` for none. |

### getRenderer() <span id="method-getRenderer"></span>

```php
public function getRenderer(): class-string<Yii3\Debug\Web\GridColumnRenderer>
```

Returns the renderer GridView resolves this column through.

**Returns**

`class-string<`[`GridColumnRenderer`](/docs/extensions/yii3-debug/reference/web/gridcolumnrenderer/index.md)`>`: Renderer class GridView instantiates for this column.

### isVisible() <span id="method-isVisible"></span>

```php
public function isVisible(): bool
```

Returns whether the column renders.

**Returns**

`bool`: `true` when the column renders; `false` when it is hidden.