ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: nuno.nogueira on February 11, 2014, 06:33:47 pm
-
Is it possible to calculate a total for certain columns without using grouping?
I have in colModel:
summary:{
type:["sum"],
title: ["<b style='font-weight:bold;'>Total:</b> {0}"]}
},
Which doesn't show any total.
If I group the 3 columns for which I want totals, it does calculate the totals but it looks really weird since these are values columns (that shouldn't be grouped).
-
If you need totals without using grouping, then this one is for you.
http://paramquery.com/pro/demos/summary
======================
It's not right to group by the same column for which you want summary. Please have a re-look at the grouping demo.
-
My data is remote, therefore, I need to count the total number of rows in the table to create the loop.
var numRegistos=$('#tabela').pqGrid("option","totalRecords");
Is returning "null", therefore, no totals.
How can I count the total number of rows?
-
Total number of rows available on client side is dataModel.data.length
-
Ok, so this returns the number of rows:
$('#tabela').pqGrid("option","dataModel.data.length");
So how do I sum the totals for a given row??
Using a loop seems ok but what kind of method/option shall I use?
This doesn't work:
for (var i = 0; i < numRegistos; i++) {
orcamentoTotal += parseFloat($('#tabela').pqGrid("getCell",{rowIndx:i, dataIndx:"orcamento"}));
};
I read the API and searched for examples but I couldn't find anything.
-
dataModel.data is an array of rows.
var data = $grid.pqGrid("option", "dataModel.data");
var sum = 0;
for(var i=0, len=data.length; i<len; i++){
var rowData = data[i];
sum += parseFloat( rowData["orcamento"] );
}
-
Ok, that's exaclty what I was looking for!
Thanks!
:D