# total sum with filter inside tfoot

Hi,

I am using the following code to make column sum in the final row of my table:

if (i == 0  || i == 8 || i==10 || i==12 || i==14){}else if(i==1){return "Totales:";}else{
var t = 0;
\$(this).parent().prevAll().find("td:nth-child("+(i+2)+")").each(function(){
t += parseInt( \$(this).text(), 10 ) || 0;
});
return t;}
});

This code works perfect, but I am having a problem:

I am using tablesorter and when i make a filter or sort, then it takes in consideration my total row, i create a tfoot for the total row, and then the tablesorter works well, but the total row loss his sum functionality, how i can modify the code for the sum to work on the total row inside my new tfoot tag and actualize when filter the table to update the row total values?
LVL 1
###### Who is Participating?

Author Commented:
I found the solution,

include another parent() to move outside the toot
0

PluritechnicianCommented:
Try the following :

/*if (i == 0  || i == 8 || i==10 || i==12 || i==14){

}
else*/
if(i==1) {
return "Totales:";
}
else {
var t = 0;
\$(this).filter(function() {
var isNotInsideTFOOT = \$(this).closest("tfoot").length==0; // true or false
return isNotInsideTFOOT; // http://api.jquery.com/filter/
}).parent().prevAll().find("td:nth-child("+(i+2)+")").each(function(){
t += \$(this).text() * 1;
});
return t;
}
});
0

Author Commented:
hi,

Returns zero in the total row
0

PluritechnicianCommented:
could you do a right click on the table, choose inspect element, locate the table tag, right click on it, and choose "copy html" to post it here, thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.