By Daniel Wood, 18 November 2021
This is a great UI technique I use all the time when I wish for a user to be able to select multiple rows from a portal. Rather than laboriously single-clicking rows it is much more intuitive to give the user an operating system like experience for file selection. By this I mean the use of modifier keys to select multiple rows:
Further to the above, functionality can be extended through the use of buttons (or my preference of custom menus) to carry out select all/no rows.
To start with, grab my example file here so you can follow along and explore the technique for yourself.
What you'll see in the demo is a portal like this in which selecting rows by Shift-clicking or Command-clicking lets you create an ad hoc selection of items from the list:
In the picture above we have a simple portal with 3 rows selected. The primary key values of the selected rows are stored in a field/variable of your choosing for use however you see fit.
This is achieved with the following components:
The last item on this list is purely for the script to know how many records it is dealing with for certain scenarios. The easiest way to achieve this is through an unstored calculation on the table set to the Get ( FoundCount ) function. For more on this technique refer to my earlier article here.
The script accepts the following parameters in JSON:
The script has been mostly abstracted, there are just 4 components to set up as shown below (These could very easily just be added as script parameters as well if you wish making the script 100% abstracted for use throughout your solution).
We simply need to specify, in the script, the fields for storing selected ids, the last selected id, the portal primary key, and a field to tell us how many records there are.
The script takes care of the rest and handles the various modifier key situations.
NOTE: This technique only works right now for portals that do not use portal-level filtering and sorting – it is for relationship level sorting and filtering only. This is because our script does not do any recursive looping through portal rows to achieve selection (something that would be required if portal level filtering/sorting were to be used).
What FileMaker Weetbicks article wouldn't be complete without an example file? In this you'll find everything discussed in the article. I think the best way to learn is to jump in and explore.