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) {[...]
```
for more info see: [yii2.chris-backhousepercipero.com](http://yii2.
chris-backhouse.cpercipero.com/report-grid/hom
e "yii2.
chris-backhousepercipero.com")