Search code examples
javascriptxpageslotus-domino

How to get Categorizied Column Totals into an XPageTotal Value from View column


I need to get the total sum of a column the view is categorized based on the document Id. i was able to get the total sum of the entire column with the following code:

var myView:NotesView = database.getView("totalScore")
var nav:NotesViewNavigator = myView.createViewNav();
var entry:NotesViewEntry = nav.getLast();
return entry.getColumnValues()[7];

but i need the total sum of a particular category, how can i get the total for each category?


Solution

  • You can get category totals in the same way.

    var myView:NotesView = database.getView("totalScore")
    var nav:NotesViewNavigator = myView.createViewNav();
    
    // Assuming this is a categorized view, so the first entry is a category
    var entry:NotesViewEntry = nav.getFirst();
    
    while (entry!=null) {
        // column-zero assumed to be a category
        print(entry.getColumnValues()[0] + ": " + entry.getColumnValues()[7]);
    
        var tmpEntry:NotesViewEntry = nav.getNextCategory();
        entry.recycle();
        entry=tmpEntry;
    }
    

    The last element will be the grand total where entry.getColumnValues()[0] will be empty.