Showing the current record in a list
Friday, February 13th, 2009FileMaker Pro provides a very understated black mark at the left of the current record when in list view. To make the current record more obvious, we can highlight the background with a colour.
We can script the process of identifying the current record ID in a global field. In the sample file, we created a global number field called current record ID in the Data table. In fact, it can be created in any table of your file and used across all tables.
We created a text object on the layout by simply typing a space character. Then the text object was resized to that required to completely cover the body part in the layout. So that we can see it, we set the fill to a light grey colour.
Conditional formatting was applied to the text object. We set two conditions. The formulae used are:
1
Data::current record ID = Get ( RecordID )
The first expression (simply the number 1) is always true. It sets the fill colour to white. So why do you see it as grey in Layout mode? Because conditional formatting is not evaluated in Layout mode.
Stop! You may want to re-read that last sentence - it is very useful information.
The second expression is true when the value in the global field matches the RecordID of the record. The fill colour for this overrides the first condition when the expression is true.
The script we used is very simple. It is called Record highlighter and has a single step:
Set Field [Data::current record ID; Get ( RecordID )
This places the RecordID of the current record into the global field.
Finally, we set the layout script trigger, OnRecordLoad, to run the script.
So the effect is that when a record loads* in the list, its recordID is set as the value of the global field. Since the second conditional formatting formula evaluates to true, the text object in the background of that record changes colour and highlights the record.
* A record loads when the user clicks on the record, navigates to it with the book in the status toolbar, uses the Go to Record command or uses a scripted process to switch records. Records also load when a new window is opened, a record is created or deleted, or when a Find result is returned.
A sample file of this technique is now available for download at:
http://www.ulearnit.com.au/samples/rec_hilite_list.zip
Finally, for the purists, there are some other niceties in the sample file. For example, the background text object doing the current record highlighting is anchored left and right. This means that it auto-resizes with the window. try making the window wider to see the effect. There are also hidden 'developer' notes only seen in Layout mode. Look at the conditional formatting of those text objects. It is a simple condition - true!




