forked from mdmsoft/yii2-widgets
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSerialColumn.php
More file actions
35 lines (31 loc) · 738 Bytes
/
SerialColumn.php
File metadata and controls
35 lines (31 loc) · 738 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
namespace mdm\widgets;
use yii\helpers\Html;
/**
* Description of SerialColumn
*
* @author Misbahul D Munir <misbahuldmunir@gmail.com>
* @since 1.0
*/
class SerialColumn extends Column
{
/**
* @inheritdoc
*/
public $header = '#';
/**
* @inheritdoc
*/
public function init()
{
if (!isset($this->grid->clientOptions['serialSelector'])) {
Html::addCssClass($this->contentOptions, 'serial');
$this->grid->clientOptions['serialSelector'] = 'td.serial';
}
if ($this->value === null) {
$this->value = function($model, $key, $index) {
return is_int($index) ? ($index + 1) : $index;
};
}
}
}