portal.FirstVisibleRow ( _portalName )
Get index of first visible row in a portal
Average rating: 4.4 (33 votes) Log in to vote
Arnold Kegebein Arnold Kegebein http://www.kegebein.net |
Function definition: (Copy & paste into FileMaker's Edit Custom Function window)
Calculates the index of the first visible row in a portal.
The parameter _portal is the object name of the portal.
Besides the object name for the portal, at least one object in the portal has to have an object name, too.
If the portal object name is unknown, nothing is returned.
If no object inside the portal has an object name, a question mark (?) is returned.
I was inspired by Fabrice Nordmann's function VisiblePortalRows. My cf returns only the index of the first visible row. Advantage: It does not use recursion (faster) and requires only one function parameter.
See also my function portal.rowCount to get the number of visible portal rows.
––––––––––
Instructions how to use this function:
(1) Create a portal.
(2) Give the portal an object name, e. g. "myPortal"
(3) Place an object into the portal, preferably a field from the portal table.
(4) Give this object an object name, e. g. "myField"
(5) Change to browse mode.
(6) Call the function (via data viewer or script or button): portal.FirstVisibleRow( "myPortal" )
(7) Scroll to a different row in the portal and call the function again.
(A) If the function returns 1, the very first portal row is visible. The return value 5 means, the portal is scrolled so far down, that the first four portal rows are not visible anymore.
(B) To verify the correct return value, add a label with the text "@@" to the portal. This will print the actual index of each portal row. The first index you can see in your portal should be the same value the function returns.
You may download a sample file with two portals at http://www.kegebein.net/download/PortalFirstVisibleRow.fp7.zip.
Comments
Ray, Cleveland, Ohio Dec 5, 2010 |
||
Could not get this one to work. Might be misreading the instructions. Maybe a bit more documentation on this one would help. | ||
Caps, Lisbon Jan 12, 2012 |
||
This functions doesn't work with multiple portals in the same layout, just the first one is working. Arnold, you have any idea why? |
||
Arnold Kegebein, Hamburg, Germany Jan 12, 2012 |
||
@Caps, sorry for your problems with this function. I tried it with two portals in the same layout without any problems. Remember, each portal requires an object name (used as the function parameter) AND an object inside each portal requires an object name as well! You may download a sample file (with two portals in the same layout) here: http://www.kegebein.net/download/PortalFirstVisibleRow.fp7.zip |
||
Caps, Lisbon Jan 13, 2012 |
||
Sorry, Arnold. I found the problem, It was my mistake. I was trying to create a multiportal with sort buttons, using hidden tab controls, to perform the sort. So in other to work, the script should go first to the object (Hidden TAB), then to portal, and after doing this perform you lovely custom function. Thanks for sharing it, and explain all at http://www.kegebein.net/blog/2010/08/dynamic-portal-scroll-bar/ |
||
Daniel Wood, Digital Fusion Ltd Sep 18, 2012 |
||
I really want to use this function but it looks as if this no longer works in FileMaker Pro 12 :( Any ideas for a workaround or hopes of a new version that works? The function works for the first 2 portal rows but after that ? is returned and some of the variables fail to evaluate within the function, I can only assume due to different way portals work in 12. If you have another way to obtain the first visible portal row index I'd love to hear it, thanks! |
||
Arnold Kegebein, Hamburg, Germany Sep 19, 2012 |
||
@Daniel Wood, Thank you for pointing out the problem with this function in FM12. Somehow FileMaker changed the behavior of the function GetLayoutObjectAttribut. I am not sure if this is a bug or an intended behavior. Nevertheless I created a version of this cf that will work with FM12. I posted it here BrianDunning under the name PortalFirstVisibleRow. It should be accessible soon. |
||
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.