1
|
|
|
<?php
|
2
|
|
|
/**
|
3
|
|
|
* @author Sergey Glagolev <[email protected]>
|
4
|
|
|
* @link https://github.com/shogodev/argilla/
|
5
|
|
|
* @copyright Copyright © 2003-2014 Shogo
|
6
|
|
|
* @license http://argilla.ru/LICENSE
|
7
|
|
|
* @package backend.widgets.grid
|
8
|
|
|
*/
|
9
|
|
|
Yii::import('bootstrap.widgets.TbDataColumn');
|
10
|
|
|
|
11
|
|
|
class BDataColumn extends TbDataColumn
|
12
|
|
|
{
|
13
|
|
|
/**
|
14
|
|
|
* @var bool $hideColumn дает возможность скрыть столбец, но оставить его в фильтре
|
15
|
|
|
*/
|
16
|
|
|
public $hideColumn;
|
17
|
|
|
|
18
|
|
|
public function renderFilterCell()
|
19
|
|
|
{
|
20
|
|
|
if( $this->grid->filterPosition !== BGridView::FILTER_POS_SEPARATE )
|
21
|
|
|
parent::renderFilterCell();
|
22
|
|
|
else
|
23
|
|
|
$this->renderFilterDivContent();
|
24
|
|
|
}
|
25
|
|
|
|
26
|
|
|
public function renderDataCell($row)
|
27
|
|
|
{
|
28
|
|
|
if( $this->hideColumn )
|
29
|
|
|
return;
|
30
|
|
|
|
31
|
|
|
parent::renderDataCell($row);
|
32
|
|
|
}
|
33
|
|
|
|
34
|
|
|
public function renderHeaderCell()
|
35
|
|
|
{
|
36
|
|
|
if( $this->hideColumn )
|
37
|
|
|
return;
|
38
|
|
|
|
39
|
|
|
parent::renderHeaderCell();
|
40
|
|
|
}
|
41
|
|
|
|
42
|
|
|
public function renderFooterCell()
|
43
|
|
|
{
|
44
|
|
|
if( $this->hideColumn )
|
45
|
|
|
return;
|
46
|
|
|
|
47
|
|
|
parent::renderFooterCell();
|
48
|
|
|
}
|
49
|
|
|
|
50
|
|
|
protected function renderFilterDivContent()
|
51
|
|
|
{
|
52
|
|
|
if( is_string($this->filter) )
|
53
|
|
|
echo $this->filter;
|
54
|
|
|
else if( $this->filter !== false && $this->grid->filter !== null && $this->name !== null && strpos($this->name, '.') === false )
|
55
|
|
|
{
|
56
|
|
|
echo CHtml::activeLabel($this->grid->filter, $this->name, array('id' => false, 'label' => $this->header));
|
57
|
|
|
|
58
|
|
|
if( is_array($this->filter) )
|
59
|
|
|
{
|
60
|
|
|
$htmlOptions = CMap::mergeArray(
|
61
|
|
|
array(
|
62
|
|
|
'id' => false,
|
63
|
|
|
'prompt' => ''
|
64
|
|
|
),
|
65
|
|
|
$this->htmlOptions
|
66
|
|
|
);
|
67
|
|
|
|
68
|
|
|
echo CHtml::activeDropDownList($this->grid->filter, $this->name, $this->filter, $htmlOptions);
|
69
|
|
|
}
|
70
|
|
|
else if( $this->filter === null )
|
71
|
|
|
{
|
72
|
|
|
$htmlOptions = CMap::mergeArray(
|
73
|
|
|
array(
|
74
|
|
|
'id' => false,
|
75
|
|
|
),
|
76
|
|
|
$this->htmlOptions
|
77
|
|
|
);
|
78
|
|
|
|
79
|
|
|
echo CHtml::activeTextField($this->grid->filter, $this->name, $htmlOptions);
|
80
|
|
|
}
|
81
|
|
|
}
|
82
|
|
|
}
|
83
|
|
|
} |