Calculate grand totals of all rows.

Called one time on rendering phase - before renderRows() call.
541353
public function updateGrandTotals()
    {
        // get model
        $m = $this->getIterator();

        // create DSQL query for sum and count request
        $fields = array_keys($this->totals);

        // select as sub-query
        $sub_q = $m->dsql()->del('limit')->del('order');

        $q = $this->app->db->dsql();//->debug();
        $q->table($sub_q, 'grandTotals'); // alias is mandatory if you pass table as DSQL
        foreach ($fields as $field) {
            $q->field($q->sum($field), $field);
        }
        $q->field($q->count(), 'total_cnt');

        // execute DSQL
        $data = $q->getHash();

        // parse results
        $this->total_rows = $data['total_cnt'];
        unset($data['total_cnt']);
        $this->totals = $data;
    }
980925
function _calculateRowHeight($row_number, $row) {
        if (!isset($this->_row_heights[$row_number])) {
            $this->_row_heights[$row_number] = 1;
        }

        // Do not process horizontal rule rows.
        if ($row === self::CONSOLE_TABLE_HORIZONTAL_RULE) {
            return;
        }

        for ($i = 0, $c = count($row); $i < $c; ++$i) {
            $lines = preg_split('/\r?\n|\r/', $row[$i]);
            $this->_row_heights[$row_number] = max($this->_row_heights[$row_number],
                count($lines));
        }
    }
1283176
function recalculateCellHeights(tableGrid, heights) {
        var allCells = tableGrid.getAllCells();
        return Tools.map(allCells, function (cell) {
          var height = total(cell.rowIndex, cell.rowIndex + cell.rowspan, heights);
          return {
            element: cell.element,
            height: height,
            rowspan: cell.rowspan
          };
        });
      }
368161
private Double aggregate(Datasource ds, Collection<Double> values) {
        return ((values.size() / m_intervalsPer) > ds.getXff()) ? ds.getAggregationFuction().apply(values) : Double.NaN;
    }
218596
public function calculate_totals() {

		/**
		 * @var $wpdb wpdb
		 */
		global $wpdb;

		// Set totals.
		if ( false !== $this->total_sql ) {
			$total = @current( $wpdb->get_col( $this->get_sql( $this->total_sql ) ) );
		} else {
			$total = @current( $wpdb->get_col( 'SELECT FOUND_ROWS()' ) );
		}

		$total                        = self::do_hook( 'select_total', $total, $this );
		$this->total_found            = 0;
		$this->total_found_calculated = true;

		if ( is_numeric( $total ) ) {
			$this->total_found = $total;
		}
	}
241878
def finalize( self, already_done=None ):
        """"""
        if already_done is None:
            already_done = {}
        if already_done.has_key( self ):
            return True
        already_done[self] = True
        self.filter_children()
        children = self.children
        for child in children:
            if hasattr( child, 'finalize' ):
                child.finalize( already_done)
            child.parents.append( self )
        self.calculate_totals( self.children, self.local_children )
1175581
public function allRows()
    {
        call_user_func($this->callback, new TableWidget($this->name, $this->label, $this->authSystem, $this->requiredPermissions, $this->table));
    }
1059675
public function render()
    {
        if (empty($this->_rows) || empty($this->_columns)) {
            return;
        }

        foreach ($this->_rows as $row) {
            $this->renderRowCells($row);
        }
    }
775420
def _createTotalsDict(self, headers, rows):
        
        totals = [sum(col) for col in zip(*rows)[1:]]
        return dict(zip(headers[1:], totals))
490169
def total_results(
    data: Union[List[JSONRPCResponse], JSONRPCResponse, None], *, ok: bool = True
) -> int:
    
    if isinstance(data, list):
        return sum([1 for d in data if d.ok == ok])
    elif isinstance(data, JSONRPCResponse):
        return int(data.ok == ok)
    return 0
165907
function(oTable) {
			if (!oTable || !oTable._aRowHeights) {
				return 0;
			}

			var aRowHeights = oTable._aRowHeights;
			var iEstimatedViewportHeight = oTable._getDefaultRowHeight() * oTable.getVisibleRowCount();

			// Only sum rows filled with data, ignore empty rows.
			if (oTable.getVisibleRowCount() >= oTable._getTotalRowCount()) {
				aRowHeights = aRowHeights.slice(0, oTable._getTotalRowCount());
			}

			var iInnerVerticalScrollRange = aRowHeights.reduce(function(a, b) { return a + b; }, 0) - iEstimatedViewportHeight;
			if (iInnerVerticalScrollRange > 0) {
				iInnerVerticalScrollRange = Math.ceil(iInnerVerticalScrollRange);
			}

			return Math.max(0, iInnerVerticalScrollRange);
		}
258357
private void calculateCollectionPartDescriptions() {
		collectionPartIds = new CollectionPartDescription[this.getNrofParts()];

		int displayOffset = 0;
		int count = 0;
		for (count = 0; count < getNrofParts() - 1; count++) {
			displayOffset = count * maxPartSize;
			if (displayOffset != offset) {
				collectionPartIds[count] = new CollectionPartDescription(displayOffset, maxPartSize, false);
			}
			else {
				collectionPartIds[count] = new CollectionPartDescription(displayOffset, maxPartSize, true);
				currentCollectionPartIdIndex = count;
			}
		}
		displayOffset = count * maxPartSize;
		if (displayOffset != offset) {
			collectionPartIds[count] = new CollectionPartDescription(displayOffset, getLastPartSize(), false);
		}
		else {
			collectionPartIds[count] = new CollectionPartDescription(displayOffset, getLastPartSize(), true);
			currentCollectionPartIdIndex = count;
		}
	}
990846
function() {
      this.totals = [];
      this.maxTotal = 0;
      this.bounds.reset();

      if (this.series_.length === 0)
        return;

      var firstSeries = this.series_[0];
      var lastSeries = this.series_[this.series_.length - 1];

      this.bounds.addValue(firstSeries.getTimestamp(0));
      this.bounds.addValue(lastSeries.getTimestamp(lastSeries.length - 1));

      var numSeries = this.numSeries;
      this.maxTotal = -Infinity;

      // Sum the samples at each timestamp.
      // Note, this assumes that all series have all timestamps.
      for (var i = 0; i < firstSeries.length; ++i) {
        var total = 0;
        this.series_.forEach(function(series) {
          total += series.getSample(i).value;
          this.totals.push(total);
        }.bind(this));

        this.maxTotal = Math.max(total, this.maxTotal);
      }
    }
599480
def on_add_rows(self, event):
        
        num_rows = self.rows_spin_ctrl.GetValue()
        #last_row = self.grid.GetNumberRows()
        for row in range(num_rows):
            self.grid.add_row()
            #if not self.grid.changes:
            #    self.grid.changes = set([])
            #self.grid.changes.add(last_row)
            #last_row += 1
        self.main_sizer.Fit(self)
190845
def overall( self, node ):
        """"""
        return sum( [self.value(value,node) for value in self.children(node)] )
1341378
def totals(iter, keyfunc, sumfunc):
    
    data = sorted(iter, key=keyfunc)
    res = {}

    for k, group in groupby(data, keyfunc):
        res[k] = sum([sumfunc(entry) for entry in group])

    return res
946913
def previous_row(self):
        """"""
        row = self.currentIndex().row()
        rows = self.proxy_model.rowCount()
        if row == 0:
            row = rows
        self.selectRow(row - 1)