I'm using JQuery in D7 to sum columns in a View with multiple attachments. The usual summing solutions, such as Aggregator Plus, Views Summary, ViewsCalc don't work across attached views. Everything works great except for some baffling reason it's counting the last row value twice. Can't figure out why. I've tried different Views table types, all do the same. Can't see any second value on the page or in DOM elements, hidden or otherwise.

The code to sum the values:

    yourString = jQuery(this).text();
     if ( !isNaN(parseFloat(yourString.replace(/[^0-9-.]/g, '')))){
    yourNumber = parseFloat(yourString.replace(/[^0-9-.]/g, ''));
    sumYours += yourNumber;
    return sumYours;

sumYours returns the total, but if there's a value in the last row of any attachment in the view it gets counted twice, messing up the math. The above code steps over header text (which gives NaN) and converts the currency string to a float to add them.

The Views last row does have a separate CSS class views-row-last, maybe I can check for that (not sure yet how) but this seems like a hack to mask some other issue.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.