SerialColumn
API reference › yii › grid › SerialColumn
SerialColumn displays a column of row numbers (1-based).
To add a SerialColumn to the GridView, add it to the 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.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$content | callable | This is a callable that will be used to generate the content of each cell. Default: null. | Column |
$contentOptions | array|Closure | The HTML attributes for the data cell tag. Default: []. | Column |
$filterOptions | array | The HTML attributes for the filter cell tag. Default: []. | Column |
$footer | string | The footer cell content. Default: null. | Column |
$footerOptions | array | The HTML attributes for the footer cell tag. Default: []. | Column |
$grid | GridView | The grid view object that owns this column. Default: null. | Column |
$header | string| | Default: '#'. | SerialColumn |
$headerOptions | array | The HTML attributes for the header cell tag. Default: []. | Column |
$options | array | The HTML attributes for the column group tag. Default: []. | Column |
$visible | bool | Whether this column is visible. Default: true. | Column |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Constructor. | yii\ |
__call() | Calls the named method which is not a class method. | yii\ |
__get() | Returns the value of an object property. | yii\ |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\ |
__set() | Sets value of an object property. | yii\ |
__unset() | Sets an object property to null. | yii\ |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\ |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\ |
className() static | Returns the fully qualified name of this class. | yii\ |
hasMethod() | Returns a value indicating whether a method is defined. | yii\ |
hasProperty() | Returns a value indicating whether a property is defined. | yii\ |
init() | Initializes the object. | yii\ |
renderDataCell() | Renders a data cell. | Column |
renderFilterCell() | Renders the filter cell. | Column |
renderFooterCell() | Renders the footer cell. | Column |
renderHeaderCell() | Renders the header cell. | Column |
getHeaderCellLabel() protected | Returns header cell label. | Column |
renderDataCellContent() protected | Renders the data cell content. | SerialColumn |
renderFilterCellContent() protected | Renders the filter cell content. | Column |
renderFooterCellContent() protected | Renders the footer cell content. | Column |
renderHeaderCellContent() protected | Renders the header cell content. | Column |
Property details
Section titled “Property details”$header
Section titled “$header ”public string|null $header = '#'Note that it will not be HTML-encoded.
Method details
Section titled “Method details”renderDataCellContent()
Section titled “renderDataCellContent() ”protected function renderDataCellContent(mixed $model, mixed $key, mixed $index): stringRenders 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. |
Returns
string: The rendering result