Categories | Question details Back To List | ||
The question about subtotal row Is there functionality or API to create a subtotal row for each group in dhtmlx grid ?Thanks. Answer posted by Support on Sep 09, 2008 07:43 If you mean grouped view ( grid.groupBy ) - there is no built in solution for subtotal rows. You may try to use TreeGrid instead and use parent rows as subtotals Answer posted by John on Sep 09, 2008 22:45 There are 16 rows of countable data. I want to make one subtotal for each 4 row. The layout is shown below. Is there any method to make the subtotal??? Thanks sales cost ------------------------------------- 1 3 1 3 1 3 1 3 ----------------------------------------------- subtotal :4 12 ------------------------------------------------ 1 2 1 2 1 2 1 2 ----------------------------------------------- subtotal :4 8
Answer posted by Support on Sep 10, 2008 02:19 You can add custom styled rows and use in-grid math to calculate sub-totals. Working sample sent by email Answer posted on Sep 10, 2008 03:20 Thank you for your answer.I try to add new custom row and i want to pass some parameter value into mygrid.addRow(). However, new added row's cell values show variable name like subtotal_sales and subtotal_Cost rather than the variable value. My coding is shown below. How can I pass some parameter values into mygrid.addRow()?
function subtotal() {
function sumColumn2( ind){ Answer posted by Support on Sep 10, 2008 04:58 >>mygrid.addRow('subtotal','subtotal_sales,subtotal_Cost' , 4 ) Must be mygrid.addRow('subtotal',subtotal_sales+","+subtotal_Cost, 4 ) or mygrid.addRow('subtotal',[subtotal_sales,subtotal_Cost], 4 ) Answer posted by John on Sep 13, 2008 01:12 Thank you for the support teams' samples. So I can make this subtotal. Now I want to use the method of mygrid.attachFooter mygrid.attachFooter(' Total,{#stat_total}/2, {#stat_total}/2 , {#stat_total}/2 ') to calculate the total. However, I cannot divide the value of {#stat_total} by 2.
sales cost ------------------------------------- 1 3 1 3 1 3 1 3 ----------------------------------------------- subtotal :4 12 ------------------------------------------------ 1 2 1 2 1 2 1 2 ----------------------------------------------- subtotal :4 8
Total: 8/2 40/2 <=================== should display Total: 4 20 Answer posted by Support on Sep 15, 2008 02:17 Grid doesn't provide such a functionality. But you can try to use one of the following approaches: 1) there is #stat_multi_total which allows to get a sum of products of two columns. And it for example some column in grid is hidden and each cell in it is equal to 0.5 you can do the following instead of {#stat_total}/2: ${#stat_multi_total}index1:index2 Where index1 - the index of the column where values are placed, and index2 is the index of the hidden column 2) also you can use the next approach: grid.attachEvent("onStatReady",function(){ grid.ftr.rows[1].cells[index].innerHTML = Math.round(parseFloat(grid.ftr.rows[1].cells[index].innerHTML)/2; }) There "index" is the index of the column with {#stat_total} |