Jump to content

Highlight current record in List View


Mandu
 Share

This topic is 3005 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I found a freebie at NightWind which demonstrates the technique (highlighting the current record in List View), but some of it escapes me.

Here's what I did glean from Nightwind's demo:

In my case I want the background of the current record to be a color, so I'll use that example. I place a Calculation field on the layout that's the width and height of the row, and plop the data fields on top of that. The Calc field is defined thusly, using pseudocode:

If ( Get(RecordID) = the i.d. of the current record )

then {return a Container with the image for the highlight}

else {return nothing}

For "i.d. of the current record" they use a global variable ($$ActiveRecordID) that is set during the calculation of the Record x of y field. This is magic to me, and it's not explained: isn't this solution highly dependent on the order in which objects are rendered for display? $$ActiveRecordID had better be set correctly *before* the individual rows in the list are rendered, or we'll highlight the wrong row. That means Record x of y must be rendered before the rows are rendered. How is that controlled? Position on page? Tab order? Is there a solution that doesn't depend upon a companion calculation field to work correctly?

I don't know if my question is sufficiently clear or not. Anybody?

Link to comment
Share on other sites

Record lighlighting systems only work when the user runs a script which sets the record id into a global field (or in this case for FMP 8 and later, a global variable) from where a calculation can display the graphic. This script is attached to a button covering the record row that has to be clicked on.

If the current record can be changed without clicking on the row button -- like using keyboard shortcuts or the notebook in the status area -- then the highlight won't change to follow the current record.

Link to comment
Share on other sites

  • 2 weeks later...

This was a problem that took me a long time and a lot of research to solve. Here's a sample of what I came up with. It uses the free FM Example plugin that comes with FM 7 Developer and FM 8 Pro Advanced. It has the added advantage that it works with any method of record selection (not just clicking but also moving up or down with keyboard commands).

hilite_test.zip

Link to comment
Share on other sites

  • 2 weeks later...
  • 4 years later...
  • Newbies

Tried to use the sample file, but it didn't work on FMPA11; I tweaked it a bit and got it working nicely.

Procedure:

  1. Create a global field
  2. Create a script that sets the global field with the result of "Get ( RecordID )" (using SetField)
  3. Bind the script to the OnRecordLoad trigger of the layout
  4. Apply conditional formatting on a text element (or field) using the formula "Get ( RecordID ) = layout::globalField"

I've attached the modified version below, should anyone need it :).

hilite test.zip

Link to comment
Share on other sites

  • 2 years later...

This topic is 3005 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.