4 Replies Latest reply on Mar 13, 2017 1:51 PM by philmodjunk

    Multiple portal rows without the scroll-down bar

    JosephVerrill

      Title

      Multiple portal rows without the scroll-down bar

      Post

      My goal is to create a portal with multiple portal rows, but instead of displaying every row with a scroll-down bar, I'd like to add a button that would go to the next portal row. This would allow for only one portal row to be viewed at a time. I'm imagining something similar to the go to next record function, but acting only on the specified portal records. I've found the "go to next portal row" script, would that have anything to do with this?

        • 1. Re: Multiple portal rows without the scroll-down bar
          Sorbsbuster

          Go to Next Portal Row won't work, I don't think: I've just set up a portal and a single row of the same related fields side-by-side, and when I click my 'GTNPR' button it cycles through the portal, but leave the single row of fields unchanged.  And it should, because that method displays the first matching record.

          Hmm...

          • 2. Re: Multiple portal rows without the scroll-down bar
            philmodjunk

            Here's how I've set this up in some of my projects: It uses a bit of behind the scenes "sleight of hand".

            In Manage | database | Relationships, locate the table occurrence (box) for your portal. Select it and then click the button with two green plus signs to make a copy of it. Drag this box off to the side of your graph, you do not want to link it to any other table occurrences.

            Now create a layout that refers to this new table occurrence. I'd set this up as a list or table view with each record being  single row of data as this will make it easier to monitor when you are testing the scripts we are about to create, but any format will work as far as the scripts are concerned.

            First script:

            Freeze Window
            IF [ Not IsEmpty ( PortalTable::NonBlankField) ]
                Go To Related Record [Show only related records; From table: Portaltable; Using layout: "YourNewLayout" (PortalTable2)]
                Go To Record [first]
                Set Variable [$$ID ; value: PortalTable2::SerialIDfield ]
            Else
                Go To Layout ["YourNewLayout" (PortalTable2)]
                Show All Records
                Show Omitted Only
            End IF
            Go To Layout [original layout]

            Use OnRecordLoad to perform this script automatically each time you bring up your current layout and each time you navigate to a different record on it.

            On your current layout, set up your portal with this portal filter: $$ID = PortalTable::SerialIDField

            Now your "next portal record" button can run this script:

            Freeze Window
            Go To Layout ["YourNewLayout" (PortalTable2)]
            Go To Record [next]
            Set Variable [$$ID ; value: PortalTable2::SerialIDfield ]
            Go To Layout [original layout]

            If you find that the portal filter does not update consistently, add Refresh Window [Flush Cached Join Results] to the end of both scripts.

            You should be able to figure out "first", "last", and "previous" versions of the last script on your own if you want them also.

            • 3. Re: Multiple portal rows without the scroll-down bar
              gmaendel

              I know this is a very old Post, but is this still the best way of doing this?

              I have a portal where I need to navigate it exclusively with Buttons and not allow scrolling.

              • 4. Re: Multiple portal rows without the scroll-down bar
                philmodjunk

                I can think of better ways. There really isn't much need for a portal here at all if you are going to show only one record at a time.

                 

                List ( RelatedTable::__pkRelatedTable::ID )

                 

                would return a list of primary keys from the "portal's" table that you can put into a global variable. Your "next" and "previous" buttons can pull the next or previous ID from this variable's list and set a match field in the layout table's record to link a set of fields (that can just be placed directly on the layout) to that record.

                 

                LayoutTable::__pkLayoutTableID = PortalTable::_fkLayoutTableID --> this is the relationship that a normal portal would use.

                LayoutTable::_fkSelectedPortalRecord = PortalTable 2::__pkPortalTableID

                 

                Using OnRecordLoad, do this script:

                 

                Set Variable [ $$RelatedIDs ; Value: List ( PortalTable::_fkLayoutTableID ) ]

                Set Field [ LayoutTable::_fkSelectedPortalRecord ; GetValue ( $$RelatedIDs ; 1 ) ]

                Set Variable [$$Index ; value: 1 ]

                #Add the following script step, if needed to get the screen to update:

                Commit Records

                 

                For both "previous" and "next" buttons:

                 

                Set Variable [$$Index ; value: Max ( Min ( $$Index + Get ( ScriptParameter ) ; ValueCount ( $$RelatedIDs ) ) ; 0 ) ]

                Set Field [ Set Field [ LayoutTable::_fkSelectedPortalRecord ; GetValue ( $$RelatedIDs ; $$Index ) ]

                #Add the following script step, if needed to get the screen to update:

                Commit Records

                 

                For Previous, use -1 as the script parameter. Use 1 as the parameter for Next.

                 

                You can add any fields that you want from PortalTable 2 to your layout to get a set of fields that update with each click of "Next" or "previous".

                 

                PS. I've used generic names here, please use descriptive names that will tell you the basic purpose of each table occurrence and field.