Closed newadventure079 closed 6 months ago
New in PHP 8.3:
8.3.0 Now emits E_WARNING when array values cannot be converted to int or float. Previously arrays and objects where ignored whilst every other value was cast to int. Moreover, objects that define a numeric cast (e.g. GMP) are now cast instead of ignored.
Same here, you can work around this by adding pageSummaryFunc in your column setting
Yes this is expected - the default page summary action is to DO A SUMMATION. Your columns to sum must only contain numbers and not strings --- alternatively use a pageSummaryFunc to build your own custom function to summarize.
If anyone else comes across this and sees the documentation and wonders how you can use a function to summarize when the docs say your options for pageSummaryFunc
are only a string, the source code gives more details.
/**
* @var string|Closure the summary function that will be used to calculate the page summary for the column. If
* setting as `Closure`, you can set it to an anonymous function with the following signature:
*
* ```php
* function ($data)
* ```
*
* - the `$data` variable will contain array of the selected page rows for the column.
*/
Prerequisites
master
branch of yii2-dynagrid.Steps to reproduce the issue
'showPageSummary' => true
Expected behavior and actual behavior
This line seems to be the issue:
kartik-v/yii2-grid/src/ColumnTrait.php at line 380– array_sum(['67.57%', '78.73%', '75.34%', '78.63%', ...])
It looks like it's summing the string values for the percentagesI was expecting...
No errors
Logs
Code
Environment
Browsers
Operating System
Libraries
Isolating the problem