diff --git a/docs/example-widget-math.html b/docs/example-widget-math.html index cbe42f23..721ca8c7 100644 --- a/docs/example-widget-math.html +++ b/docs/example-widget-math.html @@ -196,6 +196,13 @@

Notes

Older Notes

    +
  • In v2.24.6, added math_rowFilter option.
  • +
  • In v2.24.0 +
      +
    • Added "below" type of data-gathering (see Attribute Settings below for more info). See pull #873; thanks to LvLynx!.
    • +
    • Added math_none option which allows customizing the text added to a cell when there are no matching math elements (.
    • +
    +
  • In v2.22.0,
    • Fixed an issue with a sum column encountering a cell without a defined "data-math" attribute returning an empty string instead of zero. See issue #873.
    • @@ -249,6 +256,7 @@
    • Added "Mask Examples" section with examples, and how to use the $.tablesorter.formatMask function.
  • +
  • Added math widget in v2.16.0-beta
@@ -306,7 +314,7 @@

By default, recalculations are performed after:

@@ -352,7 +360,7 @@ math_complete : function($cell, wo, result, value, arry) { Set this option with an output formatting mask to use
-

As of v2.16.2, you can set a mask for each math cell by adding a data-math-mask data-attribute (the math part of the data-attribute is obtained from the math_data setting).

+

As of v2.16.2, you can set a mask for each math cell by adding a data-math-mask data-attribute (the math part of the data-attribute is named from the math_data setting).

<th data-math="all-sum" data-math-mask="##0.00">all-sum</th>

Javascript-number-formatter details

@@ -380,7 +388,7 @@ math_complete : function($cell, wo, result, value, arry) {

Note

+

Methods

+
+

Recalculate

+
+ Recalculate the values of all math cells within the table using the following method: +
$('table').trigger('recalculate');
+

The triggered 'recalculate' method can be renamed by modifying the math_event option.

+ This method is automatically called: +
    +
  • Tablesorter initialization.
  • +
  • After any call to a tablesorter method which updates the internal cache (e.g. "update", "updateCell", etc). The math widget listens for the updateComplete event, which occurs after the internal cache has completed updating, before recalculating values.
  • +
  • After a "filterReset".
  • +
  • And after a "filterEnd" event, or a "pagerComplete" event (if the pager is being used), but not both!
  • +
+
+
+

Attribute Settings

The math widget data-attibute setting requires two parts: type & formula @@ -624,6 +649,14 @@ $.tablesorter.formatMask('$#,##0.00 USD', 12345.678, 'prefix ', ' suffix'); +

+ Note The difference between using # and 0 in the mask, is that when a value of zero is passed to the function, the # mask will return an empty string whereas the 0 mask will return a zero. +

$.tablesorter.formatMask('$#,##0.00 USD', 0); // result: "$0.00 USD"
+$.tablesorter.formatMask('$#,###.00 USD', 0); // result: "$.00 USD"
+$.tablesorter.formatMask('$#,###.#0 USD', 0); // result: "$.00 USD"
+$.tablesorter.formatMask('$#,###.## USD', 0); // result: "$ USD"
+

+

Experiment with the mask: