We can use local array data to build the pivot
<?php
require_once '../../../php/demo/tabs.php';
?>
<!DOCTYPE html>
<html>
<head>
<title>Guriddo PivotGrid PHP Demo</title>
<link rel="stylesheet" type="text/css" media="screen" href="../../../css/jquery-ui.css" />
<link rel="stylesheet" type="text/css" media="screen" href="../../../css/trirand/ui.jqgrid.css" />
<style type="text">
html, body {
margin: 0; /* Remove body margin/padding */
padding: 0;
overflow: hidden; /* Remove scroll bars on browser window */
font-size: 75%;
}
</style>
<script src="../../../js/jquery.min.js" type="text/javascript"></script>
<script src="../../../js/trirand/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="../../../js/jquery-ui.min.js" type="text/javascript"></script>
<script src="../../../js/trirand/jquery.jqGrid.min.js" type="text/javascript"></script>
<script type="text/javascript">
$.jgrid.no_legacy_api = true;
$.jgrid.useJSON = true;
$.jgrid.defaults.width = "700";
</script>
</head>
<body>
<div>
<?php include ("pivot.php");?>
</div>
<br/>
<?php tabs(array("pivot.php"));?>
</body>
</html>
pivot.php.
<?php
require_once '../jq-config.php';
// include the jqGrid Class
require_once ABSPATH."php/PHPSuito/jqGrid.php";
// include the driver class
require_once ABSPATH."php/PHPSuito/DBdrivers/jqGridArray.php";
// Connection to the server
//require_once ABSPATH."php/jqGridArray.php";
// create the array connection
$conn = new jqGridArray();
// Create the jqGrid instance
$pivot = new jqPivotGrid($conn);
// Create a random array data
$data1 = array();
for ($i = 0; $i < 100; $i++)
{
$data1[$i]['CUSTOM'] = '703198';
$data1[$i]['EVENT'] = 'Cloverleaf Spring Campout 2014';
$data1[$i]['TRIBE'] = '1234'.($i+1);
$data1[$i]['AGE'] = "AGE_".sprintf("%02d", rand(6,14));
$data1[$i]['COUNTOFAGE'] = (int)rand(0,3);
}
// Always you can use SELECT * FROM data1
$pivot->SelectCommand = "SELECT * FROM data1 ORDER BY AGE";
// Set the url from where we obtain the data
$pivot->setData('pivot.php');
// Grid creation options
$pivot->setGridOptions(array(
"rowNum"=>10,
"height"=>200,
"sortname" => "AGE",
"shrinkToFit"=>false,
"rowList"=>array(10,20,50),
"caption"=>"Rows grouping"
));
// Grid xDimension settings
$pivot->setxDimension(array(
array("dataName"=>"CUSTOM", "width"=>90),
array("dataName" => "EVENT"),
array("dataName" => "TRIBE")
));
// Grid yDimension settings
$pivot->setyDimension(array(
array("dataName" => "AGE", "width"=>60)
));
// Members
$pivot->setaggregates(array(
array(
"member"=>'COUNTOFAGE',
"aggregator"=>'sum',
"width"=>80,
"label"=>'Sum',
"formatter"=>'integer',
"align"=>'right',
// the summary type set the sum function of the groups
"summaryType"=>'sum'
)
));
$pivot->renderPivot("#grid","#pager", true, null, true, true);