6 Replies Latest reply on Jun 7, 2010 3:29 PM by Steve Wright

    Iterating over portal rows without resetting the portal scrollbar

    BatMan

      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.

       

      As always, I appreciate your illuminating hints and ideas!

        • 1. Re: Iterating over portal rows without resetting the portal scrollbar
          ryan

          have you tried using a Variable in your script, with the variable defined as "Get ( PortalRowNumber )"

           

          then towards the end of your script, going back to that portal row by using the variable?

          maybe that will maintain the scroll bar position????

          • 2. Re: Iterating over portal rows without resetting the portal scrollbar
            BatMan

            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.

            • 3. Re: Iterating over portal rows without resetting the portal scrollbar
              Steve Wright

              Take a look at this technique of doing it also...

               

              http://forum-en.filemaker.com/t5/Using-FileMaker-Pro/Tip-Return-to-exact-portal-position-after-leaving-and-returning/m-p/50808?jump=true

               

              It is possible to determine which rows are visible on the portal and return to the exact scroll bar position, even if leaving the layout.

              With a freeze window step the user wont see anything change atall.

              • 4. Re: Iterating over portal rows without resetting the portal scrollbar
                comment_1

                 


                BatMan wrote:

                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.

                 


                • 5. Re: Iterating over portal rows without resetting the portal scrollbar
                  BatMan

                  @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???

                  • 6. Re: Iterating over portal rows without resetting the portal scrollbar
                    Steve Wright

                     


                    comment wrote:

                     

                    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

                    http://s563.photobucket.com/albums/ss76/sws-solutions/?action=view&current=scroll_bar.flv

                    You can see the few pixel jump if the top row is not a complete row, other than that.. considering what happens behind the scenes, I'm quite impressed with the results.