Footer sum based on a more complex situation (another columns, value signs, ...)

Footer sum based on a more complex situation (another columns, value signs, ...)

itajackassitajackass Posts: 121Questions: 37Answers: 3

My goal is to do a more complex sum based on another column:
Details:

This is the flow i'd like to do:

  1. var $SUM = 0;
  2. If column Type == IN then:
    2.1 IF AMOUNT > 0 THEN $sum = $sum + AMOUNT; ELSE $sum = $sum - AMOUNT;
    3 If column Type == OUT then:
    3.1 IF AMOUNT > 0 THEN $sum = $sum - AMOUNT; ELSE $sum = $sum + AMOUNT;

So this is i'm expecting:
$sum = 0;
$sum = $sum + 200;
$sum = $sum + 100;
$sum = $sum - 50;
$sum = $sum -10;

//$sum now is: 240 (i'd like to have this result) instead 340.

This is my example fiddle: http://live.datatables.net/togejizi/1/edit

If it possible i'd like to use data-in attribute i've inserted for each cell.

Replies

This discussion has been closed.