yii2-transpose-dataprovider

This is a data provider that performs data transposing.

The Transposes is done on a query object

Assuming you have a Query that outputs the following :


student | subject | grade

--------------------------

 mat    | cre     | 52

 mat    | ghc     | 40

 mat    | physics | 60

 leon   | cre     | 70

 leon   | ghc     | 80

 leon   | physics | 10



and we need our data to look as below :


student | cre | ghc | physics

------------------------------

 mat    | 52  | 40  | 60

 leon   | 70  | 80  | 10

We achive this by doing :

use Eddmash\TransposeDataProvider;


$dataProvider = new TransposeDataProvider([

     'query' => $query,

     'columnsField' => 'subject',

     'groupField' => 'student',

     'valuesField' => 'grade',

     'pagination' => [

         'pagesize' => 10  

     ]

]);



TransposeDataProvider::$columnsField By default the transposed output contains only the the columns found at on the query.

TransposeDataProvider::$extraFields to get other columns present on the query add them to