Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Sanju Thomas on Jul 29, 2009 12:30
open dhtmlx forum
treegrid sum using xml

is the a way I can tell treeGrid to sum all the child nodes using xml ? I tried with cell type math, it did not work for some reason.

<cell tyep="math"> =sum</cell> is what I have given in the xml.. am I doing something wrong ?
Answer posted by dhxSupport on Jul 30, 2009 01:44
You should use "type" attribute, not "tyep":
<cell type="math">=sum</cell>
Answer posted on Jul 30, 2009 01:50

Correct I was using type.. not "tyep".. it was typo :-)..

but it still shows "=sum" as value.. I don't want to change the columnType, I have a custom colum type for some other purpose.

Answer posted by dhxSupport on Jul 30, 2009 01:53
To calculate summ of the child nodes you should use "math" type. Or you should customize your custom eXcell type that it will make necessary math calculations if cell value is "=sum".
Answer posted by Sanju Thomas on Jul 30, 2009 10:35

here is the code and xml I uses.. what am I doing incorrect ?

code

-------

<link rel="STYLESHEET" type="text/css" href="js/dhtmlxTreePro/js/grid/dhtmlxgrid.css">

<script  src="js/dhtmlxTreePro/js/dhtmlxcommon.js"></script>
<script  src="js/dhtmlxTreePro/js/grid/dhtmlxgrid.js"></script>  
<script  src="js/dhtmlxTreePro/js/grid/dhtmlxgridcell.js"></script>
<script  src="js/dhtmlxTreePro/js/grid/dhtmlxtreegrid.js"></script>
<script  src="js/dhtmlxTreePro/js/dhtmlxtree_er.js"></script>
<script  src="js/dhtmlxTreePro/js/grid/dhtmlxtreegrid.js"></script>
<script  src="js/dhtmlxTreePro/js/grid/ext/dhtmlxtreegrid_lines.js"></script>
<script  src="js/dhtmlxTreePro/js/grid/ext/dhtmlxgrid_math.js"></script>


<div id="mygrid_container" style="width:315px;height:300px;"></div>

<body onload="doInitGrid();">


<script>

var mygrid;

function doInitGrid(){

  mygrid = new dhtmlXGridObject('mygrid_container');
  mygrid.setImagePath("js/dhtmlxTreePro/imgs/");
  mygrid.setHeader("Location,High,#cspan,#cspan");
  mygrid.attachHeader("#rspan,Open,Closed,Other");    
  mygrid.setInitWidths("168,48,48,48");
  mygrid.setColAlign("left,middle,middle,middle");
  mygrid.setColTypes("tree,er,er,er");
  mygrid.setSkin("light");
  mygrid.enableColSpan(true);
  mygrid.setSkin("light");
  mygrid.init();
  mygrid.loadXML("1.xml");
 
 
 

}

 

</script>

 

 

xml

----

<?xml version="1.0" encoding="UTF-8"?>
<rows>
 <row id="ABC">
  <cell>ABC Division</cell><cell type="math">=sum</cell><cell type="math">=sum</cell><cell type="math">=sum</cell>
  <row id="ABC Division#Last 30 Days">
   <cell>Last 30 Days</cell><cell>10</cell><cell>20</cell><cell>30</cell>
  </row>
 
  <row id="ABC Division#Last 60 Days">
   <cell>Last 60 Days</cell><cell>10</cell><cell>20</cell><cell>30</cell>
  </row>

  <row id="ABC Division#Last 90 Days">
   <cell>Last 90 Days</cell><cell>10</cell><cell>20</cell><cell>30</cell>
  </row>
 </row>
</rows>

Answer posted by dhxSupport on Jul 31, 2009 01:45
Please check if getVaue() method of the "er" eXcell type returns numeric value. If issue still occurs please provide us code of your custom eXcell type (you can send it directly to the support@dhtmlx.com)