Overview
Pre-requisites: Implementation Additional functions mfSumTotalSetFormat(thousandSep, decimalPoint) mfSumTotalSetIgnores(ignorePattern) mfSumTotalAddIgnore(singlePatternOption) mfSumTotalDelIgnore(singlePatternOption) mfSumTotalClear()
javascript widget calculator

MF Table Cell Summing Class

This javascript library function will allow the user to hold down Cntrl+Left mouse click on and off numeric table TD cells in order to sum up their contents into a temporary footer panel, showing the number of selected entries, the sum of the selected entries, the minimum value in the selected set, the maximum value in the selected set, and the mean average of the selected entries.

The script will ignore certain common non numeric values including currency codes or symbols, or %. This list can be extended and adjusted.

The script will include a window load event that initiates the summing using the mfSumTotalInit() function - which adds a window mousedown event to detect TD cell clicks.

Pre-requisites:

The function requires the .css file included, and the material-icons font to work.

Implementation

html
<link rel='stylesheet preload prefetch' as='style' href='https://fonts.googleapis.com/icon?family=Material+Icons'>

<link rel='stylesheet preload prefetch' as='style' href='https://methodfish.com/Download/MFTableCellSumming/files/latest/css/mf-table-cell-sums.css'>
<script src='https://methodfish.com/Download/MFTableCellSumming/files/latest/js/mf-table-cell-sums.js'></script>

Additional functions

mfSumTotalSetFormat(thousandSep, decimalPoint)

Use to change the thousand separator and decimal point charactersthat are expected (defaults to thousandSep="," and decimalPoint=".")

js ::  tell the class that French format numbers are expected
mfSumTotalSetFormat(" ", ","); 

mfSumTotalSetIgnores(ignorePattern)

Function used to define the full set of strings that are ignored in TD cells when parsing a number from the cell, e.g. "€123.45" will parse with "€" removed first

js ::  Set the list of ignorers when parsing cell values
mfSumTotalSetIgnores(["GBP", "£", "$", "€", "¥", "USD", "EUR", "CAD", "JPY", "%"]);
// or 
mfSumTotalSetIgnores("GBP|£|\$|€|¥|USD|EUR|CAD|JPY|%");

mfSumTotalAddIgnore(singlePatternOption)

Function used to add to the full set of strings that are ignored in TD cells when parsing a number from the cell, e.g. "€123.45" will parse with "€" removed first

js
mfSumTotalAddIgnore("JMD");

mfSumTotalDelIgnore(singlePatternOption)

Function used to remove entries from the full set of strings that are ignored in TD cells when parsing a number from the cell, e.g. "€123.45" will parse with "€" removed first

js
mfSumTotalDelIgnore("JMD");

mfSumTotalClear()

Function to remove the total panel; this function is called by the class when the user clicks Escape

js
mfSumTotalClear();


link Click to view a demo

square

About

License

Latest Release

Version 1.013 days ago