DHTMLX Docs & Samples Explorer

Math calculations

You can easily calculate values using math formulas. Also you are allowed to edit formulas on the fly by changing values in the quantity column:

Notice that this functionality can be used once you include codebase/ext/dhtmlxgrid_math.js file in the code of your grid.

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_math.js"></script>
 
 
<div id="gridbox" style="width:510px;height:220px;background-color:white;"></div>
 
 <script>
mygrid = new dhtmlXGridObject('gridbox');
mygrid.setImagePath("../../codebase/imgs/");
mygrid.setHeader("Book Title,Author,Price,Quantity,Total");
mygrid.setInitWidths("150,120,80,80,80");
mygrid.setColAlign("left,left,right,right,right");
mygrid.setColTypes("ed,ed,price,ed,ed[=c2*c3]");
mygrid.setColSorting("str,str,int,int,int");
mygrid.setMathRound(2);
mygrid.enableMathEditing(true);
mygrid.init();
mygrid.setSkin("dhx_skyblue");
mygrid.loadXML("../common/grid_math.xml");
</script>