How to create a table that updates each cell entry as tiddlers change?

167 views
Skip to first unread message

Harry

unread,
Jul 23, 2021, 7:08:25 PM7/23/21
to TiddlyWiki
Hi all,

I have a niche question about creating an auto-updating table and wonder if anyone can give me some guidance.

To illustrate the specific context, let's say I'm trying to create a table of all chairs and ranking memebers of the senate committees. The table would look like this:
| Committee | Chair | Ranking Member|
| Agriculture | 1 | 2 |
| Armed Service | 3 | 4 |

When the agriculture chair changes from “Jane Doe (FL)” to "John Smith", I have to manually change the code entry of cell 1 from "[[Jane Doe|Jane Doe (FL)]],,D,," to "John Smith,,R,,".

Instead of manually putting codes into cells 1 through 4, I wonder if there is a way that the table could update itself, since the chairs and ranking members change from time to time.

What I'm currently exploring is to creat two fields in each committee's tiddler. Say for tiddler "senate agriculture committee", I creat two fields "incumbent_chair" and "incumbent_ranking". My hope is that there can be some way that links cell 1 with the "incumbent_chair", so that whenever I change the "incumbent_chair" field, cell 1 in the table above would automatically update itself (with all the formatting noted above). So far this is not working out, and the best I can do now is to use "<$view tiddler= field=/>" which only allows the table to update cell 1 as the text of the field, not as a tiddler that can be clicked and redirected, nor can I add specific formatting as mentioned in the example above.

Is there anyway that I can write a code to reflect this need? Very much appreciate all the help!


Best

Harry


TW Tones

unread,
Jul 23, 2021, 8:08:03 PM7/23/21
to TiddlyWiki
Harry,

There are arrange of approaches you can use here. There are already dynamic table solutions or the content of your table can refer to variables or transclusion such that if they change it is reflected in your table. I tend to populate tables using the list widget so its the result of the list that finds the content even when it changes.

Using your example the table cell could contain {{senate agriculture committee!! incumbent_chair}} which means it can be nothing but the value there in.

Regards
Tones

Harry Reid

unread,
Jul 24, 2021, 9:41:30 PM7/24/21
to tiddl...@googlegroups.com
Hi Tones,

Thanks for your reminder! I have looked into the dynamic table but it seems that it does not allow me to customize the headers of columns and rows. Following your lead, I have tried to use list-links, but am still hitting some roadblocks. The code I'm currently trying is :
| !Committee | !Chair |
| !Agriculture | <<list-links "[field:of1[27341089]] [field:of2[27341089]]">> |

27341089 is a unique code I assign for agriculture chair, so when a new chair takes place, I'll update the relevant tiddler with the fields to make sure they auto-update in the table. However, the layout has a dot (see the attached pic, yellow shaded). Is there anyway that I can tweak the macro to remove the dot? Or should I try some different routes? Thanks a million!

Best
Harry


TW Tones <anthony...@gmail.com> 于2021年7月23日周五 下午8:08写道:
--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/wE7dVR_oBnc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/d5f15b6e-5496-4517-8392-a0fd8c8903c7n%40googlegroups.com.
list-link CBC.PNG

TW Tones

unread,
Jul 24, 2021, 10:35:02 PM7/24/21
to TiddlyWiki
Harry,

I suggested the list widget <$list not the list-links macro who uses bullet points for the list.

Also  I would be inclined to set your values outside the table and keep it simple in side the table

<$set name=agchair filter="[field:of1[27341089]]"> <!-- if this works? -->
<$set name=incumbent-chair value={{senate agriculture committee!!incumbent_chair}} ><!-- example like my previous one-->

| !Committee | !Chair |
| !Agriculture | <<agchair>> |

</$set></$set>

Harry

unread,
Jul 24, 2021, 11:44:56 PM7/24/21
to TiddlyWiki
Hi Tones,

Really appreciate your help and patience, and sorry for bothering you with the seemingly endless petty issues! I tried the  list widget code you suggested, but it only shows "Cedric Richmond" as a clickable link, while the list-links macros shows "Cedric Richmond" as a clickable link and allows formatting (for instance, if I put "//Cedric Richmond//,,Afro,," in the caption field, the link will be reformatted as I desire, see pic attached). Is there anyway that the list widget can do the similar thing, i.e. outputting the link in a designated format? This could achieve what I have in the attached pic and also get rid of the bullet point. Thanks again for your time and generous help to my nitpicking questions!

Best
Harry
list-link formatted CBC.PNG

TW Tones

unread,
Jul 25, 2021, 1:39:36 AM7/25/21
to TiddlyWiki
Harry,

The content inside the list widget is the template for each result it produces., unless you use the "variable" parameter.

It depends on your list widget but try;
 "//<<currentTiddler>>//,,Afro,,"
this and you will see its still not as you expect, this is because the link mechaisium imposes some styling. Also the bold uses two single quotes '' not one double quote "

You can refer to the title directly rather than use the variable name if its currentTiddler
''//{{!!title}}//,,Afro,,''
or
''// <$text text=<<varname>>/> //,,Afro,,''

But the above will not also be a link so do this (defaults to=<<currentTiddler>>)

<$link> ''//{{!!title}}//,,Afro,,''</$link>

If you needed the title to come from a  variable instead you can use the link widget and convert variable to simple text so all the formatting applies before it gets blue and linkified

<$link to=<<varname>> >''//<$text text=<<varname>>/>//,,Afro,,''</$link>

Regards
Tones

Charlie Veniot

unread,
Jul 25, 2021, 10:09:22 AM7/25/21
to TiddlyWiki
Silly question for you, Harry: do you only care about current chairs and ranking members in senate committees?  Do you think you'd ever like to see the composition of these committees at various points in time ?

Harry

unread,
Jul 25, 2021, 2:40:15 PM7/25/21
to TiddlyWiki
Hi Charilie,

For this table I only care about current chairs and ranking members as I want them to constantly auto-update as I edit other entries and the political cycle changes. I have a separate entry where I record historical committee compositions, as these entries are historical records and will not ever change, I do not need that entry to auto-update.

Best
Harry

Harry

unread,
Jul 25, 2021, 3:19:47 PM7/25/21
to TiddlyWiki
Hi Tones,

Thanks again for looking into this. Please forgive my fault of not making my point clear. My hope is to make the table cells auto-update themselves with both text and format. So far I find the list-link to be quite convenient as it allows me to assign values to the caption field and control the layout. For instance, my tiddler titled "Cedric Richmond (D-LA)" is assigned a caption field "//Cedric Richmond//,,Afro,,", so whenever the list-link widget calls for this tiddler in a table cell, it will show as a link with the desired format. If the chair changes from Cedric Richmond to Joni Ernst, I only need to edit Cedric Richmond's office field (e.g. of1[27341089]), transfer the value to Joni Ernst's office field entry, and put "__Joni Ernst__,,Female,," in her caption field, and many different tables involving these tiddlers will all auto-update. If Cedric Richmond wins the chair seat back again, I only need to alter the office field without touching the captions. Better still, since I have a consistent set of rules on formatting, I only need to assign a fixed value to the caption field and there is no need of further updates.

The list widget so far seems not to be able to do this. Its formatting process requires me to manually set the format for each table as it only regulates the format of the <<currentTiddler>>, but as the called <<currentTiddler>> changes, its format may also need to change. So when Joni Ernst succeeds Cedric Richmond, I need to go back to each table, and change the codes from <$link> ''//{{!!title}}//,,Afro,,''</$link> to <$link> ''__{{!!title}}__,,Female,,''</$link>w. And if Cedric Richmond wins the chair back later, I need to again go back to these tables and change the codes again, which contravenes my hope of making the tables auto-update themselves without manually visiting each and every of them.

Given these , would it be possible to find a simple tweak to the list-link macro's template so that I can get rid of the bullet point in my tiddlywiki? I figure this might be the easiest route but don't know how to do it. I could also be completely wrong and would appreciate any help you patiently lend.

Best
Harry

TW Tones

unread,
Jul 25, 2021, 7:56:41 PM7/25/21
to TiddlyWiki
Harry,

I understand where this confusion exists for many new users who in my opinion over rely in list-links which is a specific purpose macro to simplify things, but trying to use it other ways makes it more complex.

I have the tweak info below, but feel you would benefit understanding my design guidance. 

The generic and totally flexible way to list anything in tiddlywiki is the list widget, but it takes more time to learn. In fact look at list-links definition in $:/core/macros/list and you will find it (the list links macro) uses the list widget.
Personally I advise against hacking the list-links macro to change its behaviour, better to clone and modify it to another name or write your own.

I would also aim to always separate the formatting from the content but stick with the way you are currently doing it for now rather that rewrite. However, your different formats can be handled programmatically but in this thread you do not detail the logic involved so I can't offer a complete solution.

With respect, to solve one problem you are making another. 

To summarise my advice
  • To "auto-update" you cells in your table use a macro or transclusion in the cell that does the work of identifying and formatting the content you wish, then you never have to touch the table again. 
  • Keep the format of the content separate from the content itself, you could do this inside the macro you place in the cell

We can give you what you ask for to tweak the list-links macro. See the doco https://tiddlywiki.com/#list-links%20Macro and;
  • type An HTML element to use for the overall list element, defaulting to ul   Unordered list
  • subtype An HTML element to use for each item in the list, defaulting to li   List Items
So we can use <<list-links "filter" type:"div" subtype:"span">> to list one item without bullets.

Regards
Tones

Charlie Veniot

unread,
Jul 25, 2021, 9:26:18 PM7/25/21
to TiddlyWiki
Hey Harry,

Your use case had me pondering how I'd prototype something like that.

It wound up turning into a "brain age" exercise for me, as I went ahead and put together a wee for-the-giggles-prototype hosted here.

Although not particularly fancy, there is a bit of good stuff going on in there, making for a reference point to discuss some TiddlyWiki goodies/concepts if you have any questions about anything in there.

And loads of things to improve in there slowly and surely, a way to gradually introduce other TiddlyWiki goodies/concepts when it makes sense.

It has a little bit of HTML in there for tables, which I generally prefer over wikitext tables.  If the HTML is a little overwhelming, or simply too messy, ask and I'm sure somebody can clean things up with wikitext table instead.

Things could be cleaned up with some macros too at some point.

TW Tones

unread,
Jul 26, 2021, 3:15:54 AM7/26/21
to TiddlyWiki
Nice work Charlie!
Tones

Charlie Veniot

unread,
Jul 26, 2021, 8:49:44 AM7/26/21
to TiddlyWiki
Thank-you much.  Go ahead and make me blush.

When the mood strikes, that coding itch just needs to be scratched.

TiddlyWiki is great for quick and dirty prototyping.
Reply all
Reply to author
Forward
0 new messages