Filter question

Fellow Tiddlywikians,

I have a set of radio buttons that I use to select the value of a field that I use for filtering a list of tiddlers. This all works fine. The only thing I don’t like about this approach is when my Wiki is refreshed or freshly loaded, none of the radio buttons are selected so there is no filter output. Is it possible to have the filter output all values for this particular field if there is no radio button selected? Also, can I have a radio button setup to select all values of the field?

Thanks in advance!

Perhaps the quickest answer is to use the select widget instead. By definition radio is one of the above so unless you make a combined option (all filters) it is not possible.

  • The select widget has a default option you can set to the value of the field.
  • The select widget also allows a multiple option so you could combine different filters.

I will see if I can include an example

An example for Tiddlywiki.com

This selects from a set of titles;

  • A key advantage of the select filter is it saves the result as titles, using [[title with space]] as needed.
<$select tiddler=<<currentTiddler>> field=selection default={{!!selection}} multiple>
<$list filter='[tag[TableOfContents]sort[title]]'>
<option value=<<currentTiddler>>><$view field='title'/></option>
</$list>
</$select>

However you want to combine filters. In this example I use existing “filter tiddlers” which you could as well. These tiddlers are normally use in advanced search filter as “canned filters”. Using filter tiddlers, with the same, different or additional tags is a good way to save filters for later reuse.

You could name the filters literally if you want.


<$select tiddler=<<currentTiddler>> field=filter-selection default={{!!filter-selection}} multiple>
<$list filter='[all[shadows+tiddlers]tag[$:/tags/Filter]sort[]]'>
<option value={{!!filter}} > {{!!description}}</option>
</$list>
<option value="" >(none)</option>
</$select>

filter-selection={{!!filter-selection}}

<<tag $:/tags/Filter>>
  • Notice how one option is not inside the list
1 Like

Thanks very much. I hadn’t thought about the select widget. I will take a look and study that. If I have any further questions, I’ll post another reply.

There are times, if you have only a few items, that radio buttons can be handy.

Couldn’t you create a radio button “all filters” and put the combined filters in it?

If your field is pre-filled with all filters, then that should be the default when your Wiki is reloaded, right?

A couple of more questions. How do I default to multiple values being selected. It may be in your example, but I’m not seeing it if it is. The other question I have is how can I use the select widget without the dirty indicator going red? With the radio buttons, I used a tiddler with $:/temp so it wouldn’t do that. Can I do that with the select widget?

These are probably basic questions that I should be able to answer myself, but I’m having trouble concentrating this morning for various reasons.

My field contains only a single value because the tiddler represents a single operation I need to look at different ways of doing the filter. I’d like to think I know filters fairly well, but I do run across situations that stump me. I think this is one of those.

@HistoryBuff as a result of your questions I have continued to build some tools to help. As is often the case I find myself running down a rabbit hole, an exciting one like Alice.

Did you try my second code example on tiddlywiki.com?

How do I default to multiple values being selected.

Have the word multiple in the select widget, then normal click, ctrl-click and shift-click operations are used to select more than one.

how can I use the select widget without the dirty indicator going red?

If depends on what tiddler or field you set with the select widget, and what your settings are that define dirty. If $:/temp tiddlers do not trigger the dirty indictor use these. Otherwise the Dirty indicator is a separate issue. But do you really want a temporary non-permanent change?

I am building a solution called custom-filters. It allows to select filters from “filter tiddlers” starting with the inbuilt ones, It also assists you to create new “filter tiddlers”.

These are probably basic questions that I should be able to answer myself, but I’m having trouble concentrating this morning for various reasons.

Feel free to ask more questions, “lean on me” if you need to.

Here is my first version of the custom-filters
custom-filters.json (2.6 KB)

Thanks! I’ll take a look at your custom filters.

Interestingly, just prior to your latest post, I was able to get something functioning with the radio buttons by adding an “All” button and using a regexp search in the filter.

Works fine, but seems a bit slow. But then, I’ve noticed my whole wiki seems slow lately.

1 Like