Page Summary on Group totals

Web Tips Q & ACategory: Krajee Yii2 ExtensionsPage Summary on Group totals
chrisbee asked 9 months ago

Hi Kartik
Is it possible to have a page summary as a total of grouped columns?
I’m running a report on order-items, which is grouped by order number.  I hold a donation at the order level, so the order total adds in the donation.
At the bottom of the report, I want the summary to show a total of the order totals (which include the donations)
code for grouping is:

'group' => (!empty($params['financialReport']['showDonations'])) ? true : false,
'groupFooter'=>function ($model, $key, $index, $widget) { // Closure method
return [
'mergeColumns'=>[[3,10]], // columns to merge in summary
'content'=>[ // content to show in each summary cell
2=>'Total Paid',
3=> $model->customer_last_name . ", " . $model->customer_first_name,
'contentFormats'=>[ // content reformatting for each summary cell
12=>['format'=>'currency', 'decimals'=>2],
'contentOptions'=>[ // content html attributes for each summary cell
// html attributes for group summary row


chrisbee replied 9 months ago


I’ve found that I can sum the total before displaying the gridview and then set the pageSummary for that column to my variable;

foreach ($dataProvider->getModels() as $item) $myTotal+=$item->some_value;

‘header’ => ‘Paid’,
‘format’ => ‘html’,
‘attribute’ => function($model) {
return $model->total
‘pageSummary’ => Yii::$app->formatter->asCurrency($myTotal)


However, I have also discovered a bug in the page summary, where it cannot cope if some of the gridview columns are set visible=>false. It gets confused with the column count and displays the totals in the wrong columns.

Login or register to contribute or comment.

Login   Register