kartik-v / yii2-grid

Enhanced GridView with various utilities for Yii Framework 2.0
http://demos.krajee.com/grid
Other
556 stars 303 forks source link

Page Sumary does not include rows with negative values when use pageSummaryFunc = GRIDVIEW::F_SUM #935

Closed Bluewine closed 4 years ago

Bluewine commented 5 years ago

Prerequisites

Steps to reproduce the issue

  1. Render GridView with following config (only included those required for sumarization):

    echo GridView::widget([
    
    ***
    
    'dataProvider' => $dataProvider,
    'toolbar' => [],
    'hover' => true,
    'panel' => [
        'type' => 'info',
        'heading' => 'Detalles',
        'footerOptions' => ['class' => ''],
        'beforeOptions' => ['class' => ''],
        'afterOptions' => ['class' => '']
    ],
    'panelFooterTemplate' => '',
    'showPageSummary' => true,
    'pageSummaryPosition' => GridView::POS_BOTTOM,
    'pageSummaryRowOptions' => [
        'class' => 'kv-page-summary warning',
        'style' => 'text-align: right;',
    ],
    'columns' => [
    
        ***
    
        [
            'class' => DataColumn::class,
            'attribute' => 'monto_debe',
            'format' => 'decimal',
            'pageSummary' => true,
            'pageSummaryFunc' => GridView::F_SUM,
            'pageSummaryOptions' => [
                'prepend' => Moneda::findOne(['id' => 1])->simbolo . ' ',
                'append' => '',
            ],
            'contentOptions' => # no matter ~~
        ],
        [
            'class' => DataColumn::class,
            'attribute' => 'monto_haber',
            'format' => 'decimal',
            'pageSummary' => true,
            'pageSummaryFunc' => GridView::F_SUM,
            'pageSummaryOptions' => [
                'prepend' => Moneda::findOne(['id' => 1])->simbolo . ' ',
                'append' => '',
            ],
            'contentOptions' =>  # no matter ~~
        ],
    
        ***
    ],
    ]);

Expected behavior and actual behavior

When I follow those steps, I see the following: image

The column DEBE is 14 units more than the column HABER, right?

The database table accessing for those rows is: image

The red-arrowed row with a negative value, -14, is not being included by GridView to sumarize rows.

I was expecting something like the following: image

Here, I changed at database level the value -14 to 14 so the column DEBE is 28 units greater than the column HABER. The orange text is used to show up the expected correct value.

OBS: The value of the second column, HABER is the desired value to be appearing in both column, for DEBE and for HABER simultaneously.

Environment

No needed

Browsers

Operating System

Libraries

***
use kartik\detail\DetailView;
use kartik\grid\DataColumn;
use kartik\grid\GridView;
use yii\data\ArrayDataProvider;
***
stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.