Shiraz Dynamic table with Numerical summary questions!

demo

is there way to adjust the sum format (from 23 to 23.00) and also adjust the number column format?

Hi @QLXR
I have looked in the Shiraz plugin and can’t find anything relating to your question.
However, maybe you could use a function to define the field format.
See nesting functions
Imperial to metric.json (232 Bytes)
Failing that, someone else may be able to provide the answer.

This much is explicit at Shiraz section on dynamic-table column templates:

  • A template is a tiddler tagged with one of below tags
    • $:/tags/Table/HeaderTemplate for header template
    • $:/tags/Table/BodyTemplate for body template
    • $:/tags/Table/FooterTemplate for footer template

This establishes that the footers can have their own templates, and I can confirm that these column templates in general are powerful.

I’ve not tinkered with the footer templates in particular. It’s not clear to me whether different footers (for the same column) can be formatted differently. Or rather, I’m pretty sure they can (based on whether footer “cell” is working with <<sum>> or <<count>> etc.), but I haven’t tried to figure out how to make that conditional styling work in practice.

Any chance we could get a word from @Mohammad ?

You can see this in tutorial:
Open Shiraz 2.9.7 — create stylish contents in Tiddlywiki
Look at the explanation, it states the math macro are defined in $:/plugins/kookma/shiraz/macros/dtables/maths.
Now edit $:/plugins/kookma/shiraz/macros/dtables/maths and change as you like
For your case:
change
\define sum() <$text text={{{ [subfilter$(getFieldOrIndex)$sum[]] }}}/>
to
\define sum() <$text text={{{ [subfilter$(getFieldOrIndex)$sum[]] +[fixed[2]] }}}/>

As @Springer explained footers comes from footer templates. The macros or functions can be defined in the templates or as I used in an helper tiddler.

1 Like

i end up with create another procedure below, it works…

\procedure sum_format(country,currency)

<$transclude $variable="number" value=<<sum>> country=<<country>> style=currency currency=<<currency>>/>

\end

plus

/*\
title: Number.js
type: application/javascript
module-type: macro

returns a formatted number
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.name   = "number";
exports.params = [ { name: "value" }, { name: "country" }, { name: "style" }, { name: "currency" } ];
exports.run    = function(value,country,style,currency) {
      return Intl.NumberFormat( country||"en-US", { style:style||"decimal", currency:currency||"USD" } ).format(value);
   };
})();
1 Like