-
Notifications
You must be signed in to change notification settings - Fork 10
/
ECheckBoxColumn.php
89 lines (81 loc) · 2.67 KB
/
ECheckBoxColumn.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
/**
* ECheckBoxColumn class file.
*
* @license http://www.yiiframework.com/license/
*/
Yii::import('zii.widgets.grid.CCheckBoxColumn');
/**
*
*/
class ECheckBoxColumn extends CCheckBoxColumn
{
public $sortable = false;
public function getDataCellContent($row)
{
if (method_exists(get_parent_class($this), 'getDataCellContent')) {
return parent::getDataCellContent($row);
}
ob_start();
$this->renderDataCellContent($row, $this->grid->dataProvider->data[$row]);
return ob_get_clean();
}
protected function renderHeaderCellContent()
{
if (trim($this->headerTemplate) === '') {
echo $this->grid->blankDisplay;
return;
}
$item = '';
if ($this->selectableRows === null && $this->grid->selectableRows > 1) {
$item = CHtml::checkBox($this->id.'_all', false, array(
'class' => 'select-on-check-all dropdown-toggle',
'data-toggle' => 'dropdown',
));
} elseif ($this->selectableRows > 1) {
$item = CHtml::checkBox($this->id.'_all', false);
} else {
ob_start();
parent::renderHeaderCellContent();
$item = ob_get_clean();
}
?>
<div class="dropdown">
<?php echo strtr($this->headerTemplate, array('{item}' => $item));
?>
<ul class="dropdown-menu" aria-labelledby="<?php echo $this->id;
?>_all" role="menu">
<li>
<?php echo CHtml::link('<i class="icon-ok"></i> '.Yii::t('EDataTables.edt', 'Select all'), '#', array(
'id' => "{$this->id}-select-all",
'class' => 'dropdown-select-all',
));
?>
</li>
<li>
<?php echo CHtml::link('<i class="icon-remove"></i> '.Yii::t('EDataTables.edt', 'Deselect all'), '#', array(
'id' => "{$this->id}-deselect-all",
'class' => 'dropdown-deselect-all',
));
?>
</li>
<li class="divider"></li>
<li>
<?php echo CHtml::link('<i class="icon-ok"></i> '.Yii::t('EDataTables.edt', 'Select on page'), '#', array(
'id' => "{$this->id}-select-page",
'class' => 'dropdown-select-page',
));
?>
</li>
<li>
<?php echo CHtml::link('<i class="icon-remove"></i> '.Yii::t('EDataTables.edt', 'Deselect on page'), '#', array(
'id' => "{$this->id}-deselect-page",
'class' => 'dropdown-deselect-page',
));
?>
</li>
</ul>
</div>
<?php
}
}