-
Notifications
You must be signed in to change notification settings - Fork 7
/
ButtonColumn.php
43 lines (39 loc) · 1.04 KB
/
ButtonColumn.php
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
36
37
38
39
40
41
42
43
<?php
namespace mdm\widgets;
use yii\helpers\Html;
/**
* Description of ButtonColumn
*
* @author Misbahul D Munir <[email protected]>
* @since 1.0
*/
class ButtonColumn extends Column
{
/**
*
* @var boolean Show add button
*/
public $showButtonAdd = true;
/**
* @var string Icon for header
*/
public $headerIcon = '<span class="glyphicon glyphicon-plus"></span>';
/**
* @var string Icon for delete button
*/
public $deleteIcon = '<span class="glyphicon glyphicon-trash"></span>';
/**
* @inheritdoc
*/
public function init()
{
if ($this->showButtonAdd) {
$id = $this->grid->options['id'] . '-add-button';
$this->header = Html::a($this->headerIcon, '#', ['id' => $id]);
if (!isset($this->grid->clientOptions['btnAddSelector'])) {
$this->grid->clientOptions['btnAddSelector'] = '#' . $id;
}
}
$this->value = Html::a($this->deleteIcon, '#', ['data-action' => 'delete']);
}
}