Skip to content

Commit

Permalink
Fix #913: Enhance column to set own pageSummaryFormat
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-v committed Jun 18, 2019
1 parent 939d901 commit 9405dc8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ Change Log: `yii2-grid`

## Version 3.3.2

**Date:** _under development_
**Date:** 18-Jun-2019

- (enh #913): Enhance column to set own `pageSummaryFormat`.
- (bug #910): Float THead minified plugin asset error.
- (bug #907): Fixed bug with undefined offset inside rendering summary row when using string columns keys (Yuriy Mamaev)
- (enh #906): Allow setting page summary colspan direction (`ltr` or `rtl`)
Expand Down
15 changes: 14 additions & 1 deletion src/ColumnTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,18 @@ trait ColumnTrait
*/
public $pageSummaryOptions;

/**
* @var string|array|Closure in which format should the value of each data model be displayed as (e.g. `"raw"`, `"text"`, `"html"`,
* `['date', 'php:Y-m-d']`). Supported formats are determined by the [[GridView::formatter|formatter]] used by
* the [[GridView]]. Default format is "text" which will format the value as an HTML-encoded plain text when
* [[\yii\i18n\Formatter]] is used as the [[GridView::$formatter|formatter]] of the GridView.
*
* If this is not set - it will default to the `format` setting for the Column.
*
* @see \yii\i18n\Formatter::format()
*/
public $pageSummaryFormat;

/**
* @var string the horizontal alignment of each column. Should be one of [[GridView::ALIGN_LEFT]],
* [[GridView::ALIGN_RIGHT]], or [[GridView::ALIGN_CENTER]].
Expand Down Expand Up @@ -323,7 +335,8 @@ protected function renderPageSummaryCellContent()
}
$content = $this->getPageSummaryCellContent();
if ($this->pageSummary === true) {
return $this->grid->formatter->format($content, $this->format);
$format = isset($this->pageSummaryFormat) ? $this->pageSummaryFormat : $this->format;
return $this->grid->formatter->format($content, $format);
}
return ($content === null) ? $this->grid->emptyCell : $content;
}
Expand Down

0 comments on commit 9405dc8

Please sign in to comment.