|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- <?php
-
-
- namespace yii\grid;
-
- use Closure;
- use yii\base\Object;
- use yii\helpers\Html;
-
-
- class Column extends Object
- {
-
-
- public $grid;
-
-
- public $header;
-
-
- public $footer;
-
-
- public $content;
-
-
- public $visible = true;
-
-
- public $options = [];
-
-
- public $headerOptions = [];
-
-
- public $contentOptions = [];
-
-
- public $footerOptions = [];
-
-
- public $filterOptions = [];
-
-
-
-
- public function renderHeaderCell()
- {
- return Html::tag('th', $this->renderHeaderCellContent(), $this->headerOptions);
- }
-
-
-
- public function renderFooterCell()
- {
- return Html::tag('td', $this->renderFooterCellContent(), $this->footerOptions);
- }
-
-
-
- public function renderDataCell($model, $key, $index)
- {
- if ($this->contentOptions instanceof Closure) {
- $options = call_user_func($this->contentOptions, $model, $key, $index, $this);
- } else {
- $options = $this->contentOptions;
- }
- return Html::tag('td', $this->renderDataCellContent($model, $key, $index), $options);
- }
-
-
-
- public function renderFilterCell()
- {
- return Html::tag('td', $this->renderFilterCellContent(), $this->filterOptions);
- }
-
-
-
- protected function renderHeaderCellContent()
- {
- return trim($this->header) !== '' ? $this->header : $this->getHeaderCellLabel();
- }
-
-
-
- protected function getHeaderCellLabel()
- {
- return $this->grid->emptyCell;
- }
-
-
-
- protected function renderFooterCellContent()
- {
- return trim($this->footer) !== '' ? $this->footer : $this->grid->emptyCell;
- }
-
-
-
- protected function renderDataCellContent($model, $key, $index)
- {
- if ($this->content !== null) {
- return call_user_func($this->content, $model, $key, $index, $this);
- } else {
- return $this->grid->emptyCell;
- }
- }
-
-
-
- protected function renderFilterCellContent()
- {
- return $this->grid->emptyCell;
- }
- }
|