Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
478
Calculate column totals for group on client-side in grouped grid?
posted

I'm having a little trouble calculating column totals in a grouped grid. I've started from the sample code in http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=3467, and I can calculate row totals fine. Here is the code I'm using in the AfterExitEditMode handler:

 function UltraWebGrid1_AfterExitEditModeHandler(gridName, cellId){
    try {
        var cell = igtbl_getCellById(cellId);
        var row = cell.getRow();
       
        // update row and column totals

        // snip... row totals are fine
       
        // deal with column totals
        if(row.ParentRow.GroupByRow) {
            // ParentRow is the group row, get child rows (ie rows in this group)
            var rows = row.ParentRow.getChildRows();
            // get column to update
            var column = cell.Column;
            var colTotal = 0;
            for(var i = 0; i < rows.length; i++) {
                colTotal += parseFloat(row.ParentRow.getChildRow(i).getCellByColumn(column).getValue());
            }
            alert(colTotal);
            // place value in column footer
            // snip... I'll worry about this later
        }
    } catch(ex) {
        alert(ex.message);
    }
}

The problem is that row.ParentRow.getChildRow(i) returns null. I have also tried rows.getRow(i) - but the rows collection, while it is a collection and has the right length, doesn't even have a getRow method. I have also tried row.ParentRow.FirstChild, which also returns null.

Anybody know how to do this?