rice-framework/krad-web/src/main/webapp/krad/scripts/krad.utility.js
/**
 * Calculates a total/calculation for a column with the specified parameters
 *
 * @param totalDiv div of the total field
 * @param start start of the rows to total
 * @param end end of the rows to total
 * @param currentColumn the current column
 * @param aaData all the data
 * @param aiDisplay the rows display order
 */
Calculates a total/calculation for a column with the specified parameters


Calculates a total / calculation for a column with the specified parameters
function calculateTotal(totalDiv, start, end, currentColumn, aaData, aiDisplay) {
    if (totalDiv.length && totalDiv.data("function")) {
        var totalType = totalDiv.data("role");
        var dataIndex = currentColumn;
        var functionName = totalDiv.data("function");
        var extraData = totalDiv.data("params");
        var total = 0;
        var values = new Array();
        var hasInvalidValues = false;
        for (var i = start; i < end; i++) {
            var currentRow;
            var currentCell;
            if (totalType == "total") {
                currentRow = aaData[i];
            }
            else if (totalType = "pageTotal") {
                currentRow = aaData[aiDisplay[i]];
            }
            var value;
            if (currentRow != null && typeof currentRow === 'object' && !jQuery.isArray(currentRow)) {
                value = currentRow['c' + dataIndex].val;
                if (value == null) {
                    value = "";
                }
            }
            else {
                currentCell = currentRow[dataIndex];
            }
            var isAddLine = currentCell && jQuery(currentCell).find(":input[name^='newCollectionLines']").length;
            if (!isAddLine) {
                value = coerceTableCellValue(currentCell, true);
            }
            else {
                continue;
            }
            value = convertComplexNumericValue(value);
            if (value == undefined || (value && !jQuery.isNumeric(value))) {
                hasInvalidValues = true;
                continue;
            }
            if (value != "") {
                value = parseFloat(value);
                values.push(value);
            }
        }
        if (!hasInvalidValues) {
            if (extraData != undefined) {
                total = executeFunctionByName(functionName, window, values, extraData);
            }
            else {
                total = executeFunctionByName(functionName, window, values);
            }
        }
        else {
            total = "N/A";
        }
        var totalValueSpan = totalDiv.find("[data-role='totalValue']");
        if (totalValueSpan.length) {
            totalValueSpan.html(total);
        }
        else {
            var newSpan = jQuery("<span data-role='totalValue'>" + total + "</span>");
            totalDiv.append(newSpan);
        }
    }
}
function calculateTotal ( totalDiv , start , end , currentColumn , aaData , aiDisplay ) { if ( totalDiv . length && totalDiv . data ( "function" ) ) { var totalType = totalDiv . data ( "role" ) ; var dataIndex = currentColumn ; var functionName = totalDiv . data ( "function" ) ; var extraData = totalDiv . data ( "params" ) ; var total = 0 ; var values = new Array ( ) ; var hasInvalidValues = false ; for ( var i = start ; i < end ; i ++ ) { var currentRow ; var currentCell ; if ( totalType == "total" ) { currentRow = aaData [ i ] ; } else if ( totalType = "pageTotal" ) { currentRow = aaData [ aiDisplay [ i ] ] ; } var value ; if ( currentRow != null && typeof currentRow === 'object' && ! jQuery . isArray ( currentRow ) ) { value = currentRow [ 'c' + dataIndex ] . val ; if ( value == null ) { value = "" ; } } else { currentCell = currentRow [ dataIndex ] ; } var isAddLine = currentCell && jQuery ( currentCell ) . find ( ":input[name^='newCollectionLines']" ) . length ; if ( ! isAddLine ) { value = coerceTableCellValue ( currentCell , true ) ; } else { continue ; } value = convertComplexNumericValue ( value ) ; if ( value == undefined || ( value && ! jQuery . isNumeric ( value ) ) ) { hasInvalidValues = true ; continue ; } if ( value != "" ) { value = parseFloat ( value ) ; values . push ( value ) ; } } if ( ! hasInvalidValues ) { if ( extraData != undefined ) { total = executeFunctionByName ( functionName , window , values , extraData ) ; } else { total = executeFunctionByName ( functionName , window , values ) ; } } else { total = "N/A" ; } var totalValueSpan = totalDiv . find ( "[data-role='totalValue']" ) ; if ( totalValueSpan . length ) { totalValueSpan . html ( total ) ; } else { var newSpan = jQuery ( "<span data-role='totalValue'>" + total + "</span>" ) ; totalDiv . append ( newSpan ) ; } } }
Calculates a total/calculation for a column with the specified parameters
Calculates a total / calculation for a column with the specified parameters
// Calculate the total for all rows, even outside this page
 //check if row is a rowObject - using mData setting
 //skip over cells which contain add line content
 //set hasInvalidValues to true if value is undefined
 //skip over value when blank
