[TW5] Populating a SelectWidget with the indexes/values of dataTiddler

123 views
Skip to first unread message

Ghislain SILLAUME

unread,
Aug 11, 2015, 10:39:33 AM8/11/15
to TiddlyWiki
Dear all,

I'm discovering TiddlyWiki since a couple of weeks. It's a fantastic tool but I'm still not able to manage all the 'magic'...

I would like to populate a select box by iterating on this dataTiddler (The indexes are the quarters of a year and the value the corresponding dates for the date of start of the quarter):

Q1/14:20140101 Q2/14:20140401 Q3/14:20140701 Q4/14:20141001 Q1/15:20150101 Q2/15:20150401 Q3/15:20150701 Q4/15:20151001

I did find how to iterate on a dataTiddler [quarters] and display indexes and values here: http://tobibeer.github.io/tb5/#Iterate%20DataTiddler%20Indexes

Unfortunately, it's not working in the context of a selectWidget with the following code (The values of the selectWidget are filled with 'true'):

<$select field="start_date">
<$list filter="[[quarters]indexes[]sort[title]]">
<option value=<$transclude tiddler=[quarters] index=<<currentTiddler>>/> >
<$text text=<<currentTiddler>>/>
</option>
</$list>

</$select>

Any ideas?

Thank you very much for your help.

Best Regards,
Ghislain

Andreas Hahn

unread,
Aug 11, 2015, 10:57:49 AM8/11/15
to tiddl...@googlegroups.com
Am 11.08.2015 um 16:39 schrieb Ghislain SILLAUME:
Any ideas?

Hi,

try:

\define valueFromIndex()
[[data]getindex[$(index_key)$]]
\end

<$select field="start_date">
<$list filter="[[data]indexes[]sort[title]]" variable="index_key">
<$list filter=<<valueFromIndex>> variable="index_value">
<option value=<<index_value>> >
<<index_key>>
</option>
</$list>
</$list>
</$select>
Also, you can't put a widget as an argument to another widget (and HTML-tags are widgets too).


/Andreas

Andreas Hahn

unread,
Aug 11, 2015, 10:59:15 AM8/11/15
to tiddl...@googlegroups.com
Oh, and don't forget to change "data" back to the name of the tiddler you want it to work on. Both in the macro and in the list filter.

Ghislain SILLAUME

unread,
Aug 11, 2015, 11:26:06 AM8/11/15
to TiddlyWiki
It works perfectly.

Many thanks!
Ghislain

Eric Shulman

unread,
Aug 11, 2015, 2:03:07 PM8/11/15
to TiddlyWiki
On Tuesday, August 11, 2015 at 8:26:06 AM UTC-7, Ghislain SILLAUME wrote:
It works perfectly.
Am 11.08.2015 um 16:57 schrieb Andreas Hahn:

Here's a more compact implementation without any macros:

<$select field="start_date">
<$list filter="[[quarters]indexes[]sort[title]]" variable="key">
<$set name="val" filter="[[quarters]getindex
<key>]">
<option value=<
<val>>><<key>></option>
</$set>
</$list>
</$select>

enjoy,
-e
Eric Shulman
ELS Design Studios
TiddlyTools - "Small Tools for Big Ideas!"
InsideTiddlyWiki: The Missing Manuals

YOUR DONATIONS ARE VERY IMPORTANT!
HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"...

Professional TiddlyWiki Consulting Services...
Analysis, Design, and Custom Solutions:

Reply all
Reply to author
Forward
0 new messages