Title

Iterating over portal rows without resetting the portal scrollbar

Post

Hi

here's another problem with FM Pro 11 Advanced on MAC OS X: I have a layout with a portal showing related records of a different table. Each portal row has a checkbox, which takes values 1 or nothing (i.e. checked or unchecked). Also, there is a button on this layout (outside the portal) for checking/unchecking all portal rows at once. This button is attached to a script that iterates over all portal rows, checking/unchecking the checkboxes. The problem is that the current position of the scroll bar of the portal is lost when iterating over the portal rows. How can I prevent this? Jumping back to Get ( ActivePortalRowNumber ) can still move the view a little. I also tried to iterate over the related records in a different layout, but when I switch back to the original layout the scrollbar is reset to the top row. The "reset scrollbar when exiting record" option in the portal setup is unchecked.

Oh, sorry for the confusion, that's of course what I meant that I did. In the beginning of the script, I set

Set Variable [$portalRow; Value:Get ( ActivePortalRowNumber )]

and in the end

If [$portalRow > 0]

Go to Portal Row [Select; No dialog; $portalRow]

Else

Go to Field []

End If

In neither case (no row selected ($portalRow = 0) or some row selected ($portalRow > 0)) this works. In particular, if $portalRow > 0, the portal shows the $portalRow-th row on top of the portal, regardless of where in the portal is was shown before. (This is of course perfectly correct behaviour for the commands used.)

EDIT: So here's a possible solution I just came up with: Add a second portal, make it as small as possible (5x5 pixels) and hide it below something else, e.g. the first portal. Name it "HiddenPortal" or so. In the script, insert the following command at the beginning: Go to Object [Object Name: "HiddenPortal"]. Then operate on that portal instead of the original one. Still somewhat unsatisfactory, but at least it seems to work.

here's a possible solution I just came up with: Add a second portal ... Then operate on that portal instead of the original one.

I think it would be better not to operate on ANY portal. Instead, go to the related records in their own table, and do the loop there. If you do this in a new window, and close it after being done, you will return to your original layout as you left it.

@comment: Flashing windows are not acceptable in my situation. I'm building a runtime application for clients.

@SWS: Thanks for the link. I tried that, but It doesn't exactly do what I want. I want the portal not to move even a pixel. Your suggestion jumps to the row which is currently selected in the portal, and shows that one as the top row, but if the scrollbar is set such that the top row is only partly visible, or not the same as the one selected, it still changes a little. I need to be able to jump to non-integral multiples of the portal row height, in pixels from the top. The portal view is not supposed to move a single pixel.

The second portal thing is still the only way I'm achieving this so far, although only if the layout is not changed.

BTW: Why is my Get ( ActivePortalRowNumber ) not called Get ( PortalRowNumber ), like mentioned here or in the online function reference???

I think it would be better not to operate on ANY portal. Instead, go to the related records in their own table, and do the loop there. If you do this in a new window, and close it after being done, you will return to your original layout as you left it.

The problem is, on windows this is rather clunky.. especially if you are designing the solution to be maximised in the FM application window. Ever since the jump from FM6 to FM7 onwards, opening new windows is now very apparent.

I agree, the technique I have adopted is not 100% flawless, especially if the top portal row is not a complete row, you do get a small amount of shifting, but... its still a lot better than the effects of having to use new windows or losing the portal position altogether.

For example : Seedcode's calendar converted to work in a single maximised window with a scrollable view