yii2-grid icon indicating copy to clipboard operation
yii2-grid copied to clipboard

groupFooter.content.GridView::F_SUM prints "f_sum"

Open maxxer opened this issue 1 year ago • 2 comments

Prerequisites

  • [x] I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • [x] The issue still exists against the latest master branch of yii2-grid.
  • [x] This is not an usage question. I confirm having gone through and read the documentation and demos.
  • [x] This is not a general programming / coding question. (Those should be directed to the webtips Q & A forum).
  • [x] I have attempted to find the simplest possible steps to reproduce the issue.
  • [ ] I have included a failing test as a pull request (Optional).

Steps to reproduce the issue

echo GridView::widget([
    'filterModel' => $searchModel,
    'dataProvider' => $dataProvider,
    'columns' => [
        [
            'attribute' => 'company',
            'group' => true,
            'groupFooter' => function ($model, $key, $index, $widget) {
                return [
                    'mergeColumns' => [[0, 1, 2]],
                    'contentOptions' => [
                        0 => ['style' => 'font-weight: bold;'],
                        3 => ['style' => 'text-align: right;'],
                    ],
                    'content' => [
                        0 => $model['company'],
                        3 => GridView::F_SUM,
                    ],
                ];
            },
        ],
        'title',
        [
            'attribute' => 'start_time',
            'format' => 'dateTime',
            'hAlign' => 'right',
        ],
        [
            'attribute' => 'tracking_minutes',
            'format' => 'duration',
            'hAlign' => 'right',
        ],
    ],
]);

Expected behavior and actual behavior

immagine

I don't know if it matters, the ActiveDataProvider query comes from a (new Query) and not from an AR find()

Environment

Browsers

  • [x] Google Chrome
  • [x] Mozilla Firefox
  • [ ] Internet Explorer
  • [ ] Safari

Operating System

  • [ ] Windows
  • [x] Mac OS X
  • [ ] Linux
  • [ ] Mobile

Libraries

  • jQuery version: v3.6.3
  • yii2-grid version: c407f8e

Isolating the problem

  • [ ] This bug happens on the demos page
  • [x] The bug happens consistently across all tested browsers
  • [ ] This bug happens when using yii2-grid without other plugins.

maxxer avatar Mar 14 '23 15:03 maxxer

A friend appointed me the F_SUM feature works in javascript, so with plain integer/float values. I tied removing the format option from all columns, but still won't sum

maxxer avatar Mar 27 '23 09:03 maxxer

Yes the F_SUM (means a numeric summation) and needs a numeric value in each cell in the specific Grid DataColumn for summary to be mathematically possible. You need to ensure that the DataColumn value is numeric and you can use the DataColumn content property to format the data content for display.

kartik-v avatar Mar 29 '23 03:03 kartik-v