DHTMLX Docs & Samples Explorer

Pivot tables

Pivot table allows to quickly create crosstabs.
You can set it instead of the grid or separately and then choose fields and operation.

Source
<link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxgrid.css">
<link rel="stylesheet" type="text/css" href="../../codebase/skins/dhtmlxgrid_dhx_skyblue.css">
<script  src="../../codebase/dhtmlxcommon.js"></script>
<script  src="../../codebase/dhtmlxgrid.js"></script>
<script  src="../../codebase/dhtmlxgridcell.js"></script>    
<script  src="../../codebase/ext/dhtmlxgrid_pivot.js"></script>
 
 
 
            <div>
                <input type="button" name="a1" value="show external pivot" onclick="mygrid.makePivot('gridboxP')" />
                <input type="button" name="a1" value="show pivot" onclick="mygrid.makePivot()" />
                <input type="button" name="a1" value="hide pivot" onclick="mygrid.hidePivot()" />
            </div>
            <div id="gridbox" style="width:600px;height:270px;background-color:white;"></div>
            <div>
                <input type="button" name="a1" value="limited field set" onclick="mygrid.makePivot('gridboxP',{column_list:[null,'Title','Author','Money']})" />
                <input type="button" name="a1" value="predefined set" onclick="mygrid.makePivot('gridboxP',{x:1,y:2,value:3,action:0})" />
                <input type="button" name="a1" value="predefined set + readonly" onclick="mygrid.makePivot('gridboxP',{x:1,y:2,value:3,action:0,readonly:true})" />
            </div>
            <div id="gridboxP" style=" width:600px; height:270px; background-color:white; background-color:silver;"></div>
 
<script>
mygrid = new dhtmlXGridObject('gridbox');
mygrid.setImagePath("../../codebase/imgs/");
mygrid.setHeader("Sales,Book Title,Author,Price,In Store,Shipping,Bestseller,Date of Publication");
mygrid.setInitWidths("50,150,100,80,80,80,80,200");
mygrid.setColAlign("right,left,left,right,center,left,center,center");
mygrid.setColTypes("dyn,edtxt,ed,price,ch,co,ra,ro");
mygrid.init();
mygrid.setSkin("dhx_skyblue");
mygrid.loadXML("../common/100.xml");
</script>