Difference between #2 and #3 of
Yii2 Report Grid

Revision #3 has been created by CeBe on Mar 25, 2018, 2:04:21 AM with the memo:

update headlines
« previous (#2) next (#4) »

Changes

Title unchanged

Yii2 Report Grid

Category unchanged

Tips

Yii version changed

2.0

Tags changed

GgridVview, report

Content changed

A Yii2 Gridview designed specifically for reporting ------------------===================================================
 

There are some very advanced grids in the Yii2 community, specifically Kartik's amazing gridview extensions but they all designed for interactive screen use.
[...]
But more importantantly it has sub-totalling and report totalling built into the gridview itself.

### Why is this significant
Because it enables you to use closures (anonymous functions) within the sub-total fields. For example, say we want to build a report on order items, with a break at order level. At the order level, we want to report something off the order model but the dataProvider is on the order-item level.
[...]

```php
$ php composer.phar require chrisb34/reportgrid "@dev" ``` or add:
```php
"chrisb34/yii2-report-grid": "@dev" ``` to the require section of your composer.json file. Then run:
```php
php composer.phar update ``` to get the updated package on your application install. ### Widget Setup
As with most Yii2 widgets, you control the using options on widget creation. This widget is based on the Yii2 gridview widget, so anything mentioned here is over and above the base options on the gridview widget
[...]
Usage

```php

echo ReportGrid::widget([
'dataProvider' => $dataProvider,
[...]
```

### Column Configuration
When you use sub-totalling in a report, your report layout must follow the same structure as your query. So the first thing is to define your query with the results in the correct order.
[...]
Usage


```php

'subTotal' => [
'breakValue' => function($model, $key, $index, $widget, $break) {
if ($break == 1)
return $model->category_name;
elseif ($break == 0)
[...]
6 0
7 followers
Viewed: 33 510 times
Version: 2.0
Category: Tips
Written by: Chris Backhouse
Last updated by: Chris Backhouse
Created on: Jul 11, 2017
Last updated: 6 years ago
Update Article

Revisions

View all history