# SerialColumn

> SerialColumn displays a column of row numbers (1-based).

[API reference](/docs/api/index.md) › [yii](/docs/api/yii/index.md) › [grid](/docs/api/yii/grid/index.md) › SerialColumn

| class | `yii\grid\SerialColumn` |
| --- | --- |
| Extends | [`Column`](/docs/api/yii/grid/column/index.md) » [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| Implements | [`yii\base\Configurable`](/docs/api/yii/base/configurable/index.md) |
| Since | 2.0 |
| Source | [`framework/grid/SerialColumn.php`](https://github.com/yiisoft/yii2/blob/22.0/framework/grid/SerialColumn.php#L31) |

SerialColumn displays a column of row numbers (1-based).

To add a SerialColumn to the [`GridView`](/docs/api/yii/grid/gridview/index.md), add it to the [columns](/docs/api/yii/grid/gridview/index.md#property-columns) configuration as follows:

```
'columns' => [
    // ...
    [
        'class' => 'yii\grid\SerialColumn',
        // you may configure additional properties here
    ],
]
```

For more details and usage information on SerialColumn, see the [guide article on data widgets](/docs/guide/output-data-widgets/index.md).

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-content"></span>[`$content`](/docs/api/yii/grid/column/index.md#property-content) | `callable` | This is a callable that will be used to generate the content of each cell. Default: `null`. | [`Column`](/docs/api/yii/grid/column/index.md) |
| <span id="property-contentOptions"></span>[`$contentOptions`](/docs/api/yii/grid/column/index.md#property-contentOptions) | `array\|`[`Closure`](https://www.php.net/manual/en/class.closure.php) | The HTML attributes for the data cell tag. Default: `[]`. | [`Column`](/docs/api/yii/grid/column/index.md) |
| <span id="property-filterOptions"></span>[`$filterOptions`](/docs/api/yii/grid/column/index.md#property-filterOptions) | `array` | The HTML attributes for the filter cell tag. Default: `[]`. | [`Column`](/docs/api/yii/grid/column/index.md) |
| <span id="property-footer"></span>[`$footer`](/docs/api/yii/grid/column/index.md#property-footer) | `string` | The footer cell content. Default: `null`. | [`Column`](/docs/api/yii/grid/column/index.md) |
| <span id="property-footerOptions"></span>[`$footerOptions`](/docs/api/yii/grid/column/index.md#property-footerOptions) | `array` | The HTML attributes for the footer cell tag. Default: `[]`. | [`Column`](/docs/api/yii/grid/column/index.md) |
| <span id="property-grid"></span>[`$grid`](/docs/api/yii/grid/column/index.md#property-grid) | [`GridView`](/docs/api/yii/grid/gridview/index.md) | The grid view object that owns this column. Default: `null`. | [`Column`](/docs/api/yii/grid/column/index.md) |
| [`$header`](#property-header) | `string\|null` | Default: `'#'`. | `SerialColumn` |
| <span id="property-headerOptions"></span>[`$headerOptions`](/docs/api/yii/grid/column/index.md#property-headerOptions) | `array` | The HTML attributes for the header cell tag. Default: `[]`. | [`Column`](/docs/api/yii/grid/column/index.md) |
| <span id="property-options"></span>[`$options`](/docs/api/yii/grid/column/index.md#property-options) | `array` | The HTML attributes for the column group tag. Default: `[]`. | [`Column`](/docs/api/yii/grid/column/index.md) |
| <span id="property-visible"></span>[`$visible`](/docs/api/yii/grid/column/index.md#property-visible) | `bool` | Whether this column is visible. Default: `true`. | [`Column`](/docs/api/yii/grid/column/index.md) |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| <span id="method-__construct"></span>[`__construct()`](/docs/api/yii/base/baseobject/index.md#method-__construct) | Constructor. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-__call"></span>[`__call()`](/docs/api/yii/base/baseobject/index.md#method-__call) | Calls the named method which is not a class method. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-__get"></span>[`__get()`](/docs/api/yii/base/baseobject/index.md#method-__get) | Returns the value of an object property. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-__isset"></span>[`__isset()`](/docs/api/yii/base/baseobject/index.md#method-__isset) | Checks if a property is set, i.e. defined and not null. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-__set"></span>[`__set()`](/docs/api/yii/base/baseobject/index.md#method-__set) | Sets value of an object property. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-__unset"></span>[`__unset()`](/docs/api/yii/base/baseobject/index.md#method-__unset) | Sets an object property to null. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-canGetProperty"></span>[`canGetProperty()`](/docs/api/yii/base/baseobject/index.md#method-canGetProperty) | Returns a value indicating whether a property can be read. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-canSetProperty"></span>[`canSetProperty()`](/docs/api/yii/base/baseobject/index.md#method-canSetProperty) | Returns a value indicating whether a property can be set. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-className"></span>[`className()`](/docs/api/yii/base/baseobject/index.md#method-className) static | Returns the fully qualified name of this class. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-hasMethod"></span>[`hasMethod()`](/docs/api/yii/base/baseobject/index.md#method-hasMethod) | Returns a value indicating whether a method is defined. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-hasProperty"></span>[`hasProperty()`](/docs/api/yii/base/baseobject/index.md#method-hasProperty) | Returns a value indicating whether a property is defined. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-init"></span>[`init()`](/docs/api/yii/base/baseobject/index.md#method-init) | Initializes the object. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-renderDataCell"></span>[`renderDataCell()`](/docs/api/yii/grid/column/index.md#method-renderDataCell) | Renders a data cell. | [`Column`](/docs/api/yii/grid/column/index.md) |
| <span id="method-renderFilterCell"></span>[`renderFilterCell()`](/docs/api/yii/grid/column/index.md#method-renderFilterCell) | Renders the filter cell. | [`Column`](/docs/api/yii/grid/column/index.md) |
| <span id="method-renderFooterCell"></span>[`renderFooterCell()`](/docs/api/yii/grid/column/index.md#method-renderFooterCell) | Renders the footer cell. | [`Column`](/docs/api/yii/grid/column/index.md) |
| <span id="method-renderHeaderCell"></span>[`renderHeaderCell()`](/docs/api/yii/grid/column/index.md#method-renderHeaderCell) | Renders the header cell. | [`Column`](/docs/api/yii/grid/column/index.md) |
| <span id="method-getHeaderCellLabel"></span>[`getHeaderCellLabel()`](/docs/api/yii/grid/column/index.md#method-getHeaderCellLabel) protected | Returns header cell label. | [`Column`](/docs/api/yii/grid/column/index.md) |
| [`renderDataCellContent()`](#method-renderDataCellContent) protected | Renders the data cell content. | `SerialColumn` |
| <span id="method-renderFilterCellContent"></span>[`renderFilterCellContent()`](/docs/api/yii/grid/column/index.md#method-renderFilterCellContent) protected | Renders the filter cell content. | [`Column`](/docs/api/yii/grid/column/index.md) |
| <span id="method-renderFooterCellContent"></span>[`renderFooterCellContent()`](/docs/api/yii/grid/column/index.md#method-renderFooterCellContent) protected | Renders the footer cell content. | [`Column`](/docs/api/yii/grid/column/index.md) |
| <span id="method-renderHeaderCellContent"></span>[`renderHeaderCellContent()`](/docs/api/yii/grid/column/index.md#method-renderHeaderCellContent) protected | Renders the header cell content. | [`Column`](/docs/api/yii/grid/column/index.md) |

## Property details

### $header <span id="property-header"></span>

```php
public string|null $header = '#'
```

Note that it will not be HTML-encoded.

## Method details

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

```php
protected function renderDataCellContent(mixed $model, mixed $key, mixed $index): string
```

Renders the data cell content.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$model` | `mixed` | The data model |
| `$key` | `mixed` | The key associated with the data model |
| `$index` | `mixed` | The zero-based index of the data model among the models array returned by [`GridView::$dataProvider`](/docs/api/yii/widgets/baselistview/index.md#property-dataProvider). |

**Returns**

`string`: The rendering result