My attempt at an editable table

260 views
Skip to first unread message

Stephen Kimmel

unread,
Apr 28, 2017, 1:55:54 PM4/28/17
to TiddlyWiki

I have been a big fan of the editable tables since Danielo first introduced his. I have both his routine and Jed Carty gave us his RowTable and Column Table macros they have been part of my standard package. But like 90% of the folks in this group, I can't leave well enough alone, so I developed my own version of an online editable table.

I have two reasons for posting this: 1) The nature of the group is such that if you come up with something potentially useful to someone else, you share it. Therefore... and 2) Although it is functional, it is still a bit clunky. I still have problems with in tiddler macros and this one has a highly repetitive bit of code that practically screams out to be a macro. I am hoping that someone will take a look at what I've done and tell me what I'm missing. And if someone has a more elegant way to do this, I would love to see their answer.

The link is http://my-table.tiddlyspot.com/

In general, each of the column headings is a select-widget that will allow you to pick any field for any of the columns other than the first. The column headings are not the actual field names but captions so they can be more explanatory and less arcane. Any field in the main body of the table is actually an edit-text widget linked to the appropriate tiddler. Clicking on the entry will start editing it. It has a sort and filter section above which uses the same list of fields as the column headings. This means that you can filter or sort by any of the fields whether they are shown on the table or not. I've styled the table so that the edit-text boxes aren't obviously edit boxes and the column headings aren't obviously selects.

Thanks ahead of time for any suggestions.

Stephen


Message has been deleted

Stephen Kimmel

unread,
May 1, 2017, 9:26:53 AM5/1/17
to TiddlyWiki
Let me pose my question more directly. I assume the answer is obvious to the more experienced hands.

The following code is not working correctly and I don't understand why. I would like the macro FieldChoice to return a select widget with a list of captions taken from the dictionary tiddler FieldsData.
I get the Select that works but all the captions match the one for the default entry in FieldThing. The problem appears to be passing the parameter fieldName from FieldChoice to FieldThing. The code below is just one of my many failed attempts.

\define FieldChoice(name:"title")
<$select field="field1" default='title'>
<option value="">none</option>
<$set name="currentTiddler" value="FieldsData">
<$list filter="[all[current]indexes[]]" variable="fieldName">
<option value=<<fieldName>>><<FieldThing $(fieldName)$>>
</
option>
</$list>
</
$set>
</$select>
\end

\define FieldThing(name:"current_address")
{{FieldsData##$name$}}
\end

<<FieldChoice field1>>

Can someone tell me what I've done wrong and how to do this correctly?

Eric Shulman

unread,
May 1, 2017, 11:46:02 AM5/1/17
to TiddlyWiki
On Monday, May 1, 2017 at 6:26:53 AM UTC-7, Stephen Kimmel wrote:
...problem appears to be passing the parameter fieldName from FieldChoice to FieldThing...

\define FieldChoice(name:"title")
<$select field="field1" default='title'>
<option value="">none</option>
<$set name="currentTiddler" value="FieldsData">
<$list filter="[all[current]indexes[]]" variable="fieldName">
<option value=<<fieldName>>><<FieldThing $(fieldName)$>>
</
option>
</$list>
</
$set>
</$select>
\end

\define FieldThing(name:"current_address")
{{FieldsData##$name$}}
\end

<<FieldChoice field1>>

Can someone tell me what I've done wrong and how to do this correctly?

Within the macro syntax, $(varname)$ expands values that are defined in variables **outside the macro definition** (i.e., using <$set> or <$vars>) and $varname$ expands values that are **passed as arguments** to the macro call.  To reference a variable that has been **defined within the current scope** (i.e., the "fieldName" variable defined by the <$list> widget) you need to use the <<varName>> syntax.

However, because you are passing <<varName>> as a parameter to another macro, you can't just use <<varName>> because the <<...>> syntax doesn't "nest". Thus, the following macro syntax does NOT work:
   <<FieldThing <<fieldName>>>>

Fortunately, there is an alternative *widget* syntax for making a macro call, that does allow you to use the <<...>> syntax to specify parameters:
<$macrocall $name="FieldThing" name=<<fieldName>> />

That should do it.
Let me know how it goes.

enjoy,
-e
Eric Shulman
TiddlyTools.com: "Small Tools for Big Ideas" (tm)
InsideTiddlyWiki: The Missing Manuals

Stephen Kimmel

unread,
May 1, 2017, 1:38:54 PM5/1/17
to TiddlyWiki
Thanks, Eric.

That's what I needed. And I feel a good less like a moron for not figuring that out on my own.

Jeremy might want to consider expanding the explanation to clarify the various syntax at work here.

Stephen

Jeremy Ruston

unread,
May 1, 2017, 1:53:51 PM5/1/17
to tiddl...@googlegroups.com
Hi Stephen

> Jeremy might want to consider expanding the explanation to clarify the various syntax at work here.

There was an update from Mark S. in January that covers pretty much the exact issue you encountered:

http://tiddlywiki.com/#Concatenating%20text%20and%20variables%20using%20macro%20substitution

Of course, finding such information in the documentation remains hard.

Best wishes

Jeremy

Ste Wilson

unread,
May 1, 2017, 4:37:18 PM5/1/17
to TiddlyWiki
Another thing I'll have to have a look at soon... Too many great toys to tinker with..

At the risk of putting a spanner in the works I mostly access my tiddlywikkis in my mobile and I don't seem to be able to scroll/ see any of the table off screen.

Could it play nice with the Mathcell plugin?

Stephen.

@TiddlyTweeter

unread,
May 3, 2017, 7:50:20 AM5/3/17
to TiddlyWiki
I want to come back to the original post and demo.

I think its beautiful.

I know its partly taking forward what others have done before but its looking very marketable in this presentation. A really good integration. Its taken a lot on board and it works well even as is.

The SORTING is very interesting as it allows for values OUTSIDE the table itself. I know no other HTML table like that. Its a real new for me.

The one thing it could do with (but I'm not sure its anyway possible) is the ability to SUM columns. Then it would do all basic math I'd ever need for basic accounts. I have looked at a spreadsheet add-on for TW that does that. Its over complex & heavy on the JavaScript.

Just perceptions
Josiah 


Stephen Kimmel

unread,
May 4, 2017, 5:33:59 PM5/4/17
to TiddlyWiki
This one may be heading in the direction you are looking for. It includes a modified version of Eruc Shulman's column calculation routine that he wrote for tiddlywiki classic. It is still klunky and should be used with caution but it is a "proof of concept" version at this point. Still it may be useful.

http://my-table.tiddlyspot.com/
Reply all
Reply to author
Forward
0 new messages