1 | <?php |
||
22 | class Column extends Object |
||
23 | { |
||
24 | /** |
||
25 | * @var GridView the grid view object that owns this column. |
||
26 | */ |
||
27 | public $grid; |
||
28 | /** |
||
29 | * @var string the header cell content. Note that it will not be HTML-encoded. |
||
30 | */ |
||
31 | public $header; |
||
32 | /** |
||
33 | * @var string the footer cell content. Note that it will not be HTML-encoded. |
||
34 | */ |
||
35 | public $footer; |
||
36 | /** |
||
37 | * @var callable This is a callable that will be used to generate the content of each cell. |
||
38 | * The signature of the function should be the following: `function ($model, $key, $index, $column)`. |
||
39 | * Where `$model`, `$key`, and `$index` refer to the model, key and index of the row currently being rendered |
||
40 | * and `$column` is a reference to the [[Column]] object. |
||
41 | */ |
||
42 | public $content; |
||
43 | /** |
||
44 | * @var bool whether this column is visible. Defaults to true. |
||
45 | */ |
||
46 | public $visible = true; |
||
47 | /** |
||
48 | * @var array the HTML attributes for the column group tag. |
||
49 | * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered. |
||
50 | */ |
||
51 | public $options = []; |
||
52 | /** |
||
53 | * @var array the HTML attributes for the header cell tag. |
||
54 | * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered. |
||
55 | */ |
||
56 | public $headerOptions = []; |
||
57 | /** |
||
58 | * @var array|\Closure the HTML attributes for the data cell tag. This can either be an array of |
||
59 | * attributes or an anonymous function ([[Closure]]) that returns such an array. |
||
60 | * The signature of the function should be the following: `function ($model, $key, $index, $column)`. |
||
61 | * Where `$model`, `$key`, and `$index` refer to the model, key and index of the row currently being rendered |
||
62 | * and `$column` is a reference to the [[Column]] object. |
||
63 | * A function may be used to assign different attributes to different rows based on the data in that row. |
||
64 | * |
||
65 | * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered. |
||
66 | */ |
||
67 | public $contentOptions = []; |
||
68 | /** |
||
69 | * @var array the HTML attributes for the footer cell tag. |
||
70 | * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered. |
||
71 | */ |
||
72 | public $footerOptions = []; |
||
73 | /** |
||
74 | * @var array the HTML attributes for the filter cell tag. |
||
75 | * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered. |
||
76 | */ |
||
77 | public $filterOptions = []; |
||
78 | |||
79 | |||
80 | /** |
||
81 | * Renders the header cell. |
||
82 | */ |
||
83 | 2 | public function renderHeaderCell() |
|
87 | |||
88 | /** |
||
89 | * Renders the footer cell. |
||
90 | */ |
||
91 | public function renderFooterCell() |
||
95 | |||
96 | /** |
||
97 | * Renders a data cell. |
||
98 | * @param mixed $model the data model being rendered |
||
99 | * @param mixed $key the key associated with the data model |
||
100 | * @param int $index the zero-based index of the data item among the item array returned by [[GridView::dataProvider]]. |
||
101 | * @return string the rendering result |
||
102 | */ |
||
103 | 5 | public function renderDataCell($model, $key, $index) |
|
112 | |||
113 | /** |
||
114 | * Renders the filter cell. |
||
115 | */ |
||
116 | public function renderFilterCell() |
||
120 | |||
121 | /** |
||
122 | * Renders the header cell content. |
||
123 | * The default implementation simply renders [[header]]. |
||
124 | * This method may be overridden to customize the rendering of the header cell. |
||
125 | * @return string the rendering result |
||
126 | */ |
||
127 | 1 | protected function renderHeaderCellContent() |
|
128 | { |
||
129 | 1 | return trim($this->header) !== '' ? $this->header : $this->getHeaderCellLabel(); |
|
130 | } |
||
131 | |||
132 | /** |
||
133 | * Returns header cell label. |
||
134 | * This method may be overridden to customize the label of the header cell. |
||
135 | * @return string label |
||
136 | * @since 2.0.8 |
||
137 | */ |
||
138 | 1 | protected function getHeaderCellLabel() |
|
139 | { |
||
140 | 1 | return $this->grid->emptyCell; |
|
141 | } |
||
142 | |||
143 | /** |
||
144 | * Renders the footer cell content. |
||
145 | * The default implementation simply renders [[footer]]. |
||
146 | * This method may be overridden to customize the rendering of the footer cell. |
||
147 | * @return string the rendering result |
||
148 | */ |
||
149 | protected function renderFooterCellContent() |
||
153 | |||
154 | /** |
||
155 | * Renders the data cell content. |
||
156 | * @param mixed $model the data model |
||
157 | * @param mixed $key the key associated with the data model |
||
158 | * @param int $index the zero-based index of the data model among the models array returned by [[GridView::dataProvider]]. |
||
159 | * @return string the rendering result |
||
160 | */ |
||
161 | protected function renderDataCellContent($model, $key, $index) |
||
169 | |||
170 | /** |
||
171 | * Renders the filter cell content. |
||
172 | * The default implementation simply renders a space. |
||
173 | * This method may be overridden to customize the rendering of the filter cell (if any). |
||
174 | * @return string the rendering result |
||
175 | */ |
||
176 | protected function renderFilterCellContent() |
||
180 | } |
||
181 |