hedera-web/js/db/calc-sum.js

50 lines
666 B
JavaScript
Raw Normal View History

/**
* Computes a sum of data in the model.
**/
Db.CalcSum = new Class
({
Extends: Db.Calc
,Tag: 'db-calc-sum'
,getRowValue: function (row)
{
var value;
if (this._func)
{
this._set.row = row;
value = this._func (this._set);
}
else
value = this._model.getByIndex (row, this.columnIndex);
return value;
}
,before: function (row)
{
var value = this.getRowValue (row)
if (value !== null)
2016-05-06 12:09:15 +00:00
this._sum -= value;
}
,after: function (row)
{
var value = this.getRowValue (row);
if (value !== null)
2016-05-06 12:09:15 +00:00
this._sum += value;
}
,init: function ()
{
2016-05-06 12:09:15 +00:00
this._sum = 0;
}
,done: function ()
{
2016-05-06 12:09:15 +00:00
this.value = this._sum;
}
});