Categories | Question details Back To List | ||
How to sum user data using customGroupFormat and forEachRowInGroup Hi, I want to sum user data and display it in the grid group header. User data is loaded with xml (within <row>) <userdata name='DureeCumuleeDecimal'>9.9</userdata> I've got a customGroupFormat hook up to the grid I want to know how to use forEachRowInGroup to loop and return the sum of each user data DureeCumuleeDecimal in the group and then display it in the group header. Here's what I want to get : Sum DureeCumuleeDecimal = 11.65 Here is the grid xml <?xml version="1.0" encoding="iso-8859-1"?><rows><head> <column type='ro' width='75' sort='str' id='Ligne' idx='0'>Ligne</column> <column type='ro' width='50' sort='int' id='OF' idx='1'>OF</column> <column type='ro' width='75' sort='int' id='Produit' idx='2'>Produit</column> <column type='ro' width='150' sort='str' id='Description' idx='3'>Description</column> <column type='ro' width='100' sort='str' id='Début' idx='4'>Début</column> <column type='ro' width='100' sort='str' id='Fin' idx='5'>Fin</column> <column type='ro' width='75' sort='str' id='Durée cumulée' idx='6'>Durée cumulée</column> <column type='ro' width='75' sort='str' id='Arrêts Direct' idx='7'>Arrêts Direct</column> <column type='ro' width='75' sort='str' id='Arrêts Ind.' idx='8'>Arrêts Ind.</column> <column type='ron' width='75' sort='int' id='Efficacité' format='0.0%' idx='9'>Efficacité</column> <column type='ro' width='75' sort='str' id='Durée MOD' idx='10'>Durée MOD</column> <column type='ron' width='75' sort='int' format='0.0' id='Moy. MOD' idx='11'>Moy. MOD</column> <column type='ron' width='75' sort='int' format='0.0' id='Std. MOD' idx='12'>Std. MOD</column> <column type='ro' width='75' sort='str' id='Durée MOI' idx='13'>Durée MOI</column> <settings> <colwidth>px</colwidth> </settings> </head><row><cell idx='0' id='Ligne'>LGN01</cell><cell idx='1' id='OF'>18579</cell><cell idx='2' id='Produit'>WEB04147</cell><cell idx='3' id='Description'><![CDATA[0470 PE-PP 5.5MM GR#30 3.35M]]></cell><cell idx='4' id='Début'>2009-02-10 07:00</cell><cell idx='6' id='Fin'>2009-02-10 16:54</cell><cell idx='7' id='Durée cumulée'>9h54</cell><userdata name='DureeCumuleeDecimal'>9.9</userdata><cell idx='8' id='Arrêts Direct'>0h35</cell><cell idx='9' id='Arrêts Ind.'>6h15</cell><cell idx='10' id='Efficacité'>31.0%</cell><cell idx='11' id='Durée MOD'>29h42</cell><cell idx='12' id='Moy MOD'>3.08</cell><cell idx='13' id='Std MOD'>3</cell><cell idx='14' id='Durée MOD'>13h30</cell></row><row><cell idx='0' id='Ligne'>LGN01</cell><cell idx='1' id='OF'>18579</cell><cell idx='2' id='Produit'>WEB04147</cell><cell idx='3' id='Description'><![CDATA[0470 PE-PP 5.5MM GR#30 3.35M]]></cell><cell idx='4' id='Début'>2009-02-10 07:00</cell><cell idx='6' id='Fin'>2009-02-10 16:54</cell><cell idx='7' id='Durée cumulée'>1h45</cell><userdata name='DureeCumuleeDecimal'>1.75</userdata><cell idx='8' id='Arrêts Direct'>0h35</cell><cell idx='9' id='Arrêts Ind.'>6h15</cell><cell idx='10' id='Efficacité'>31.0%</cell><cell idx='11' id='Durée MOD'>29h42</cell><cell idx='12' id='Moy MOD'>3.08</cell><cell idx='13' id='Std MOD'>3</cell><cell idx='14' id='Durée MOD'>13h30</cell></row></rows> Thank you. Answer posted by dhxSupport on Oct 08, 2009 02:10 Please check this article http://dhtmlx.com/dhxdocs/doku.php?id=dhtmlxgrid:grouping&s[]=groupby#math_operations_in_group-by_mode Answer posted by David Charron on Oct 08, 2009 05:17 I did check it. But I would like to get a working and more meaningfull sample of grid.forEachRowInGroup Thank you. Answer posted by dhxSupport on Oct 08, 2009 06:05 |