1: <?php
2: 3: 4: 5: 6: 7: 8: 9:
10:
11: Yii::import('bootstrap.helpers.TbHtml');
12: Yii::import('zii.widgets.grid.CDataColumn');
13:
14: 15: 16:
17: class TbDataColumn extends CDataColumn
18: {
19: 20: 21: 22:
23: public $filterInputOptions;
24:
25: 26: 27: 28:
29: protected function ()
30: {
31: if ($this->grid->enableSorting && $this->sortable && $this->name !== null) {
32: $sort = $this->grid->dataProvider->getSort();
33: $label = isset($this->header) ? $this->header : $sort->resolveLabel($this->name);
34:
35: if ($sort->resolveAttribute($this->name) !== false) {
36: $label .= '<span class="caret"></span>';
37: }
38:
39: echo $sort->link($this->name, $label, array('class' => 'sort-link'));
40: } else {
41: if ($this->name !== null && $this->header === null) {
42: if ($this->grid->dataProvider instanceof CActiveDataProvider) {
43: echo CHtml::encode($this->grid->dataProvider->model->getAttributeLabel($this->name));
44: } else {
45: echo CHtml::encode($this->name);
46: }
47: } else {
48: parent::renderHeaderCellContent();
49: }
50: }
51: }
52:
53: 54: 55:
56: public function renderFilterCell()
57: {
58: echo CHtml::openTag('td', $this->filterHtmlOptions);
59: echo '<div class="filter-container">';
60: $this->renderFilterCellContent();
61: echo '</div>';
62: echo CHtml::closeTag('td');
63: }
64:
65: 66: 67:
68: protected function renderFilterCellContent()
69: {
70: if (is_string($this->filter)) {
71: echo $this->filter;
72: } else {
73: if ($this->filter !== false && $this->grid->filter !== null && $this->name !== null && strpos(
74: $this->name,
75: '.'
76: ) === false
77: ) {
78: if ($this->filterInputOptions) {
79: $filterInputOptions = $this->filterInputOptions;
80: if (empty($filterInputOptions['id'])) {
81: $filterInputOptions['id'] = false;
82: }
83: } else {
84: $filterInputOptions = array();
85: }
86: if (is_array($this->filter)) {
87: $filterInputOptions['prompt'] = '';
88: echo CHtml::activeDropDownList(
89: $this->grid->filter,
90: $this->name,
91: $this->filter,
92: $filterInputOptions
93: );
94: } else {
95: if ($this->filter === null) {
96: echo CHtml::activeTextField($this->grid->filter, $this->name, $filterInputOptions);
97: }
98: }
99: } else {
100: parent::renderFilterCellContent();
101: }
102: }
103: }
104: }
105: