Discussion:
[tw] TW5: dynamically generate input tables?
(too old to reply)
Dave
2015-10-26 03:44:11 UTC
Permalink
In TWC you could create a dynamically generated table using
ForEachTiddlerPlugin, something like this:

<<forEachTiddler
where
'tiddler.tags.contains("ClinicalDiagnoses")'
sortBy
'store.getValue(tiddler,"wt")'
descending
write
'(index < 5) ? "| [["+tiddler.title+"]] |
("+store.getValue(tiddler,"wt")+") | +++^*@[>]...<<tiddler
"+tiddler.title+"\>\>===|\n" : ""'
Is there a relatively simple equivalent in the current TW5? I see
something like it in this thread about editable tables:

https://groups.google.com/forum/#!searchin/tiddlywiki/editable$20tables/tiddlywiki/XeCYubR8YrU/J_buhitP9zsJ

, but I was wondering if there's a simpler way (I look at that code and
don't really understand it yet) to do the same thing?




The use case is this: I'm trying to learn TW5 by making a TW for assisting
in swim coaching. I have a group of tiddlers (names of swimmers) tagged
"swimmers", and I want to be able to generate a tiddler with a table of
names and editable times based on something like this:

| <$list filter="[tag[swimmers]sort[title]]"/> | <$edit-text
tiddler="50mFreestyle" field="time"/> |

but of course this will make only one row with all the names in the first
cell and a single edit box for the one field



here's another idea I had that doesn't work:

macro:
\define race(name:"name" time:"0:00")
| $name$ | <$edit-text tiddler="50mFreestyle-$name$" field="time"/> |
\end

tiddler that calls the race macro:
<<race name:"<$list filter="[tag[swimmers]sort[title]]"/>">>



Ideally maybe there's a way to dynamically create a DataTiddler in the
DictionaryTiddler format... I'm okay with having the info attached to the
swimmers tiddlers but it would probably be better to end up with
DataTiddlers for each "race"


Any suggestions?
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/00a56a99-4914-4b33-9005-727d707830fa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
'Mark S.' via TiddlyWiki
2015-10-26 04:54:29 UTC
Permalink
This bit here:

| <$list filter="[tag[swimmers]sort[
title]]"/> | <$edit-text tiddler="50mFreestyle" field="time"/> |

needs to be rewritten something like:

<table>
<$list filter="[tag[swimmers]sort[title]]">
<tr><td><$view field="title"/></td><td><$edit-text field="50mFreestyleTime"
/> </td></tr>
</$list>
</table>

... (untested) where I assume each swimmer's tiddler has a field
"50mFreestyleTime" (You don't have to make the field in advance)

All your activity needs to happen inside of the <$list></$list> construct.
You have to be sure to balance all the tags. I've never had much luck using
the Pipes inside of <$list>, so I just use HTML table tags instead.
Post by Dave
In TWC you could create a dynamically generated table using
<<forEachTiddler
where
'tiddler.tags.contains("ClinicalDiagnoses")'
sortBy
'store.getValue(tiddler,"wt")'
descending
write
'(index < 5) ? "| [["+tiddler.title+"]] |
"+tiddler.title+"\>\>===|\n" : ""'
Is there a relatively simple equivalent in the current TW5? I see
https://groups.google.com/forum/#!searchin/tiddlywiki/editable$20tables/tiddlywiki/XeCYubR8YrU/J_buhitP9zsJ
, but I was wondering if there's a simpler way (I look at that code and
don't really understand it yet) to do the same thing?
The use case is this: I'm trying to learn TW5 by making a TW for
assisting in swim coaching. I have a group of tiddlers (names of swimmers)
tagged "swimmers", and I want to be able to generate a tiddler with a table
| <$list filter="[tag[swimmers]sort[title]]"/> | <$edit-text
tiddler="50mFreestyle" field="time"/> |
but of course this will make only one row with all the names in the first
cell and a single edit box for the one field
\define race(name:"name" time:"0:00")
| $name$ | <$edit-text tiddler="50mFreestyle-$name$" field="time"/> |
\end
<<race name:"<$list filter="[tag[swimmers]sort[title]]"/>">>
Ideally maybe there's a way to dynamically create a DataTiddler in the
DictionaryTiddler format... I'm okay with having the info attached to the
swimmers tiddlers but it would probably be better to end up with
DataTiddlers for each "race"
Any suggestions?
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/03255191-e939-404e-ab0c-2bdc56a90542%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Dave
2015-10-26 05:14:20 UTC
Permalink
Thank you Mark - that gets me headed in the right direction.

:)

I was just looking at adapting the table structure from here:
http://tiddlywiki.com/#Filter%20Operators:[[Filter%20Operators]]

just before I checked the thread, but your example is way farther than I
got doing that.
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/e639089a-1a8e-4125-8b51-5d8d40657f52%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Dave
2015-10-26 05:19:01 UTC
Permalink
Do you happen to know how to convert those tiddler titles into links? Just
adding [[ and ]] doesn't work.
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/ef12d146-b950-453b-8968-1cee74cddf91%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jed Carty
2015-10-26 08:27:45 UTC
Permalink
To make the titles links you can put <$link> and </$link> around the title
like this (using the example from mark):

<table>

<$list filter="[tag[swimmers]sort[title]]">
<tr><td><$link><$view field="title"/></$link></td><td><$edit-text
field="50mFreestyleTime" /> </td></tr>
</$list>
</table>
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/bbb69686-7182-41ee-94cc-19690cf00aaf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Dave
2015-10-26 13:42:39 UTC
Permalink
Awesome, thanks! (And it's so easy too!)
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/d8b8eaf8-fb0a-45a7-a257-f2cd61ea7f43%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Dave
2015-10-26 21:27:52 UTC
Permalink
I almost have the best case senario (a separate tiddler with appropriate
data in fields):

\define race(event:"event")
<table>
<$list filter="[tag[swimmers]sort[title]]">
<tr><td><$link><$view field="title"/></$link></td><td><$edit-text
tiddler='$event$' field='<$view field="title"/>' /></td></tr>
</$list>
</table>
\end

that macro works, e.g. <<race event:"50mFreestyle">> will construct the
table, but I can't seem to get the swimmers names as the field name in the
new tiddler [[50mFreestyle]]

the new tiddler in this case gets made with a field called "<$view
field="title"/>"


I also tried with single and double curly brackets {{ }} and that didn't
work either.

I suspect the problem is that since I specified the tiddler name just
before it the following <$view field="title"/> is not the same as the
previous <$view field="title"/> that wrote the swimmers name in the
previous table cell to the left (or at least that may be part of the
problem)

Do I have to set a variable somehow in the first cell to be able to use it
in the adjacent cell?



I tried this (didn't work):

\define race(event:"event")
<table>
<$list filter="[tag[swimmers]sort[title]]">
<tr><td><$link><$view field="title"/></$link><$set name="swimmer"
value=$title$></set></td><td><$edit-text tiddler='$event$'
field=$(swimmer)$ /></td></tr>
</$list>
</table>
\end

and this didn’t work either:

\define race(event:"event")
<table>
<$list filter="[tag[swimmers]sort[title]]">
<tr><td><$link><$view field="title"/></$link></td><td><$edit-text
tiddler='$event$' field="[tag[swimmers]sort[title]]"/></td></tr>
</$list>
</table>
\end


Any suggestions?
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/b5ee7840-d594-4247-b01a-065349c4be5a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jed Carty
2015-10-26 21:36:24 UTC
Permalink
You use {{!!title}} in this case.

\define race(event:"event")

<table>
<$list filter="[tag[swimmers]sort[title]]">
<tr><td><$link><$view field="title"/></$link></td><
td><$edit-text tiddler='$event$' field={{!!title}}/>' /></td></tr>
</$list>
</table>
\end


You may be able to get some help looking at what I made here
<http://ooktech.com/jed/ExampleWikis/DynamicTables/>.
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/8a231cdd-a16e-4cc9-b0b5-3758df6ce528%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jed Carty
2015-10-26 21:37:58 UTC
Permalink
Sorry, there was some copy-paste trouble, this is what it should be:

\define race(event:"event")

<table>
<$list filter="[tag[swimmers]sort[title]]">
<tr><td><$link><$view field="title"/></$link></td><td><$edit-text
tiddler='$event$' field={{!!title}}/></td></tr>
</$list>
</table>
\end
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/7ea140b4-0866-43bf-b48a-993dc9f3068d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Dave
2015-10-26 22:06:18 UTC
Permalink
That's It!! Thank you! I'll be using that for a long time (and your other
one from the above thread will come in handy too!)

:)
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/71fead8d-2fd6-4f11-a8f5-a3bd4a6cf51c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Dave
2015-10-28 00:33:02 UTC
Permalink
Oops, spoke too soon.

Something weird is happening with this and I've posted the problem on the
dev group:

https://groups.google.com/forum/#!topic/tiddlywikidev/ZGfZH_BVOO0
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/af39d36f-639f-449c-8055-3fdce9995b67%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Dave
2015-10-28 15:15:15 UTC
Permalink
nevermind - I did a stupid mistake: was playing around with different
versions of the same macro and left one there with the same macro name.
They were just interfering with one another.

Moral of the story, if something weird is happening with your macros,
search for "define (macroname)" (rather than "<<(macroname)")
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/1f39057d-18bc-4ef1-b775-52aba3982dc8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...