phpGrid now supports pivot grid through a simple function “set_pivotgrid“.
Simply passing the pivot configration array parameter simialr to the following such as xDimension and yDimension, aggregates as well as footer and header in the array.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | array ( "footerTotals" => 1, "footerAggregator" => "sum", "totals" => 1, "totalHeader" => "Grand Total", "totalText" => "Grand {0} {1}", "xDimension" => array ( array ( "dataName" => "status", "label" => "status", "sortorder" => "desc" ), array ( "dataName" => "ProductName", "label" => "Product Name", "footerText" => "Total:" ) ), "yDimension" => array ( array ( "dataName" => "orderDate", "sorttype" => "date", "totalHeader" => "Total in {0}" ) ), "aggregates" => array ( array ( "member" => "status", "aggregator" => "count", "summaryType" => "count", "label" => "{1}" ) ) ) |
Complete sample code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | $dg = new C_DataGrid("SELECT * FROM orders", "orderNumber", "orders"); // setting options: http://www.trirand.com/jqgridwiki/doku.php?id=wiki:pivotsettings $dg->set_pivotgrid( array ( "footerTotals" => 1, "footerAggregator" => "sum", "totals" => 1, "totalHeader" => "Grand Total", "totalText" => "Grand {0} {1}", "xDimension" => array ( array ( "dataName" => "status", "label" => "status", "sortorder" => "desc" ), array ( "dataName" => "ProductName", "label" => "Product Name", "footerText" => "Total:" ) ), "yDimension" => array ( array ( "dataName" => "orderDate", "sorttype" => "date", "totalHeader" => "Total in {0}" ) ), "aggregates" => array ( array ( "member" => "status", "aggregator" => "count", "summaryType" => "count", "label" => "{1}" ) ) ) ); $dg -> display(); |