Count on footerdata

QuestionsCount on footerdata
Joel Gomes asked 7 years ago

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

7 Answers
juliano gomes weber answered 7 years ago

i tried count-1 but doesnt work to! any idea?

Abu Ghufran answered 7 years ago

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

C3media answered 7 years ago

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!

juliano gomes weber answered 7 years ago

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

Abu Ghufran answered 7 years ago

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])

juliano gomes weber answered 7 years ago

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

juliano gomes weber answered 7 years ago

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

Your Answer

2 + 2 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?