Calculating table row and column values in TiddlyWiki

347 views
Skip to first unread message

Stephen Kimmel

unread,
May 19, 2017, 9:27:57 AM5/19/17
to TiddlyWiki
One of the commenters on my inline editable table routine suggested that it would be helpful if the routine could sum the columns. I decided that would be a helpful thing. Eric has a routine that does that for TiddlyWiki Classic but, unfortunately, it does seem to work with TW5. So I reworked and extended it myself. Eric will undoubtedly recognize a good amount of his code and documentation. No doubt, he could write my additions more elegantly than I have.

In addition to doing the sum, the count and the average of a column, I've added the minimum and maximum. I also created a separate routine to accomplish the same functions for rows.

In Eric's routine you used 
<<columncalc count all 1 -1>>

while in mine,
<<ColCalc tableID count 1 -1 all>>
or
<<RowCalc tableID count 1 -1 all>>

where the tableID refers to either an HTML table such as
<table ID="myTable">...</table>

or an HTML div such as
<div id="myTable">...</div>

that contains a wikitext table. I couldn't figure out a better way of limiting the function to the table which contains it. If someone has a better approach, I'd love to hear it.

Table cells may contain just about anything though some, such as anchors, will always be interpreted as text. When the cell contains an input box, the row and column calculations don't automatically update. I don't have a way I really like to force TW to update a displayed tiddler so I'm open to suggestions about that as well.

The routines and some examples are located at http://tablecalcs.tiddlyspot.com/

@TiddlyTweeter

unread,
May 20, 2017, 3:55:17 AM5/20/17
to TiddlyWiki
Ciao Stephen

That looks really useful. I'm playing with it & will comment later.

Best wishes
Josiah

On Friday, 19 May 2017 15:27:57 UTC+2, Stephen Kimmel wrote:
One of the commenters on my inline editable table routine suggested that it would be helpful if the routine could sum the columns...
Reply all
Reply to author
Forward
0 new messages