Hi
I need some help, i cant get count to work on my footer, this is my code:
<script>
var opts = {
'loadComplete': function () {
var grid = $("#list"),
ft = grid.jqGrid('getCol', 'fortyFT', false, 'sum');
tw = grid.jqGrid('getCol', 'twentyFT', false, 'sum');
so = grid.jqGrid('getCol', 'SOC', false, 'sum');
cb = grid.jqGrid('getCol', 'CBM', false, 'sum');
sum3 = grid.jqGrid('getCol', 'VALUE', false, 'sum');
g = sum3 * 0.9247;
c = grid.jqGrid('getCol', 'CERT_N', false, 'count');
f = grid.jqGrid('getCol', 'BL', false, 'count');
d = f * 60;
e = g + d;
grid.jqGrid('footerData','set', {fortyFT: '40ft: '+ft,
twentyFT: '20ft: '+tw,
SOC: 'Soc: '+so,
CBM: 'Cbm: '+cb,
VALUE: '$: '+sum3,
CERT_N: 'Cert: ' +c,
BL: '€: ' +e}, false);
}
};
</script>
He counts more than it should…
thank you so mutch
Extending footer-row.php, It works fine with:
var count = grid.jqGrid('getCol', 'client_id', false, 'count');
However, if you are using grouping then above line will not work. You can use jquery hack.
var count = $(".cbox").length-1
function bonus_data($data)
{
$t = $data["params"]["reference_no"];
$client_id = $data["params"]["customer_id"];
global $h;
$res = $h->execute_query("select award_points from sma_companies WHERE id = '$client_id'");
$arr = $res->GetRows();
$puntos = $arr["award_points"];
if ($puntos < "180")
{
$acu = $puntos + $t;
$h->execute_query("UPDATE sma_companies SET award_points = '$acu' WHERE id = '$client_id'");
}
else
if ($puntos > "180")
{
$h->execute_query("UPDATE sma_companies SET award_points = '$t' WHERE id = '$client_id'");
}
}
Abu this is final code , but not working; It´s no taking last row from award_points to accumulating.
Thanks by your help!
Hi Abu
i just tried with var count = $(".cbox").length-1, but still cant get to work he counts allways 2 more for each group…
any other idea?
Thank you for your help
It was just to give an idea.
It it is showing +2 for all cases, you can -2 from length.
You can also email me code + screenshot at my email ([email protected])
I did the work in a different way, getting the total grid records (your count) as the example below if anyone needs it.
instead of doing a count of the column
//c = grid.jqGrid('getCol', 'column',false, 'count');
Getting value from grid count (right down corner of the grid)
c= grid.jqGrid('getGridParam', 'records');
Thank you for your help
I did the work in a different way, getting the total grid records (your count) as the example below if anyone needs it.
instead of doing a count of the column
//c = grid.jqGrid('getCol', 'column',false, 'count');
Getting value from grid count (right down corner of the grid)
c= grid.jqGrid('getGridParam', 'records');
or
c= grid.jqGrid('getGridParam', 'reccount');
to get the record count visible on grid per page
Thank you for your help