From 9405dc8ae9f16c9c45cad1989bd66350ee13e5d6 Mon Sep 17 00:00:00 2001 From: Kartik Visweswaran Date: Tue, 18 Jun 2019 19:59:05 +0530 Subject: [PATCH] Fix #913: Enhance column to set own `pageSummaryFormat` --- CHANGE.md | 3 ++- src/ColumnTrait.php | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGE.md b/CHANGE.md index f021f761..4a268e9e 100755 --- a/CHANGE.md +++ b/CHANGE.md @@ -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`) diff --git a/src/ColumnTrait.php b/src/ColumnTrait.php index 22b0aa00..3ae75883 100644 --- a/src/ColumnTrait.php +++ b/src/ColumnTrait.php @@ -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]]. @@ -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; }