Sorting records in a dynamic table - need syntax help

131 views
Skip to first unread message

JWHoneycutt

unread,
Jan 23, 2021, 1:17:23 PM1/23/21
to TiddlyWiki

I love Mohammad's solution for dynamic-tables, (Shiraz plugin version 2.1.2) but...

I need a little more help making a dynamic table sort correctly.

I created a numeric "sort" field. Entries are (in order) 01, 021, 022, 03, 071, 101, 102, 11, etc.

My current best guess still does not work:

```
<<table-dynamic filter:"[tag[Ayacucho]tag[Owner]tag[Person]]" fields:"tbl-expand title lot name corp_name corp_number email phone" caption:"''Ayacucho Lot Owners''" class:"w-100 table-hover-cyan table-center thead-dark" footerRows:"0" stateTiddler:"$:/keepstate/dynamictables/$(sort)$" editButton:"yes">>

```

I first assumed I could just make my filter:"[tag[Ayacucho]tag[Owner]tag[Person]sort[sort]]" and leave stateTiddler:"" (blank), but it does not sort by the "sort" field.

Next try is filter:"[tag[Ayacucho]tag[Owner]tag[Person]" and stateTiddler:"sort", still fails.

How do I get the table to sort by the "sort" field?

(The sort order can be permanent.) - Do I insert this lingo here? $:/keepstate/dynamictables/$(currentTable)$ 

JWHoneycutt

Mark S.

unread,
Jan 23, 2021, 2:25:05 PM1/23/21
to TiddlyWiki
I would try the "nsort" operator rather than the sort operator.

Mohammad Rahmani

unread,
Jan 23, 2021, 2:54:12 PM1/23/21
to tiddl...@googlegroups.com
Hi JWHoneycutt

As Mark recommended, you need to use nsort.  Table has an input parameter called sortOp. The state tiddler can be anything, no need to use a complicated title. The state tiddler is used for two reasons: It keeps the state between two sessions, it keeps the footer results. So, if you don't use footers for further calculations, and if you don't need the sorting state or expand state  you can even ignore the state tiddler. 

I should mention if you use several dynamic tables in a single tiddler, again state tiddler is used to keep them separate (e.g sorting state

Best wishes
Mohammad


--
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 view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/79389ea1-4cff-45b1-b8bf-d50d016c4ac2n%40googlegroups.com.

Mohammad Rahmani

unread,
Jan 23, 2021, 3:00:09 PM1/23/21
to tiddl...@googlegroups.com

and study the sortOp.


Best wishes
Mohammad


On Sat, Jan 23, 2021 at 9:47 PM 'JWHoneycutt' via TiddlyWiki <tiddl...@googlegroups.com> wrote:
--

JWHoneycutt

unread,
Jan 23, 2021, 4:35:09 PM1/23/21
to TiddlyWiki
Now my macro is:

<<table-dynamic filter:"[tag[Ayacucho]tag[Owner]tag[Person]]" fields:"tbl-expand sort title lot name corp_name corp_number email phone" caption:"''Ayacucho Lot Owners''" sortOp:"nsort" class:"w-100 table-hover-cyan table-center thead-dark" footerRows:"0" stateTiddler:"" editButton:"yes">>

It is still sorting the filtered records by tiddler title (but I want it sorted by sort field), because there is no place where I have told it to "nsort[sort]" - right?

JWHoneycutt

unread,
Jan 23, 2021, 4:36:53 PM1/23/21
to TiddlyWiki
Only one dynamic sort in the wiki, so I am ignoring the stateTiddler setting. No math to summate. No footer.

Thanks for the help.

JWHoneycutt

JWHoneycutt

unread,
Jan 23, 2021, 6:29:29 PM1/23/21
to TiddlyWiki
My (inelegant) work around is to copy each tiddler and retitle the copy with a numeric name, in order.

My code sorts by title, and I just need to remember that when I edit fields, I need to copy the fieldValue back to the original.

Mohammad Rahmani

unread,
Jan 23, 2021, 9:58:07 PM1/23/21
to tiddl...@googlegroups.com
Note, the table is created from a filter. It i s the main input parameter. It makes the rows. After creating the table, you can click on the sort (field) column you made to sort the table based on that field.
By the way, dynamic tables have the feature to sort by each column (field), so it does not make sense to use the sort filter operator with input filter.

Hope this helps



Best wishes
Mohammad


JWHoneycutt

unread,
Jan 24, 2021, 9:33:10 AM1/24/21
to TiddlyWiki
OMG - it is embarrassing to learn that clicking the column header sorts the whole table. I should have tried that first.

Thank you Mohammad for creating this great solution. Is there a way to export to spreadsheet format (or CSV) for others (non TW5 users) to add to?

JWHoneycutt

Mohammad Rahmani

unread,
Jan 24, 2021, 1:12:23 PM1/24/21
to tiddl...@googlegroups.com
Well, I have not tried that, but I think there are solutions. Not sure but I have read threads here discussing export/import csv.


Best wishes
Mohammad


TW Tones

unread,
Jan 25, 2021, 8:20:09 PM1/25/21
to TiddlyWiki
JWHoneycutt 

To export as csv no need to think about the table plugin but once the data is there an independent export can be set up.

Although not fully documented or examples given see the https://tiddlywiki.com/#csvtiddlers%20Macro

Basically <<csvtiddlers "filter">> would generate a view of the filtered tiddlers in csv format ready for export, as far as I can see it identifies all the fields, generates A heading row and CSV's each tiddler as a row.

It is almost as easy to import CSV's back in, but the JSON mangler is your friend here, I have a utility wiki with JSON mangler for such import export then drag the result to the destination.

Regards
Tones

Reply all
Reply to author
Forward
0 new messages