10 Replies Latest reply on Jul 27, 2011 11:38 AM by yuichim

    Paging layout using portal?

    yuichim

      Title

      Paging layout using portal?

      Post

      Hi,

      Has anyone tried to create a paging layout using portal?
      I wanted something like google's result page displaying ..... let's say 20 results, but has more pages with more results.
      The question came up because I have a table that has 80,000 records and does not want to show all of them at once but only want to show 50 ~ 100 each page.

      Any help much appreciated..

        • 1. Re: Paging layout using portal?
          philmodjunk

          It can be done with a script and a filtered, non-scrolling portal. Do you have FileMaker 11?

          Do these records have a serial number field in a field of type number? Are the records displayed in the portal sorted in either ascending or descending order? (Or is it OK if they are?)

          The basic method is you use script triggers that pull up a found set of all the portal records on a hidden layout and then your forward and back buttons perform scripts that interact with this found set to set global variables to values used in the portal filter to control each "page" of data.

          If the portal records are numbered in order, this is simpler to do and executes more quickly. Without such an order, it's still possible as long as you have a primarykey field in the portal's table. (This numbering does not have to be sequential, just sorted from smallest to largest or largest to smallest.)

          • 2. Re: Paging layout using portal?
            yuichim

            Hi Phil,

            To answer your question, I do have FM11.

            Also, records do have id fields which is a serial number.
            What I am trying to achieve is to show the users company records, ie, company name - state, zip, timezone, status.....

            I would like them to be able to click on the column title (company name, state, zip, timezone, status etc...) and sort it also.  I think that would be the challenge.
            So, the paging has to be done with conjunction with column title filtering.  Is it possible?

            • 3. Re: Paging layout using portal?
              philmodjunk

              This sounds like something better done with a list or table layout--that way sorting the records becomes much easier to do. And you can still use a variation of this technique. Any reaons why you can't do this with a list or table view of the records?

              Portals can't really sort dynamically without scripting plus sorting on an unstored calculation field. Thus, it can produce performance delays when you are dealing with so many records.

              • 4. Re: Paging layout using portal?
                yuichim

                There is a layout design that I've been working with, and I don't think the table view will work.  I might be able to work with the list view though.

                • 5. Re: Paging layout using portal?
                  philmodjunk

                  Both table and list view can work with the above, though I prefer list view as table view can enable your users to mess with the column setups and this could create problems for your layout. (In layout setup, you can specify that the header layout part be visible when in table view and this would enable you to have your logo, buttons and search text field visible.)

                  In either case, you'd have to make a small adjustment to the section at far left ( My Contacts, Callbacks, Samples, Lead Pool) to move those layout objects into your header.

                  As I write this, I find I keep running into this statement you made and the ramifications complicate your approach whether you use a portal or not:

                  "I would like them to be able to click on the column title (company name, state, zip, timezone, status etc...) and sort it also."

                  That is indeed a challenge here. If you change the sort order, that could potentially change which records are visible on your page unless you only want the sort to apply to the visible records. (Say you have five records with Alabama in the state field, but only 2 show on the current page. If you sort by state, do just those two records sort to the top of your screen or do the other three now appear grouped with it?

                  • 6. Re: Paging layout using portal?
                    yuichim

                    That is a good question.  I haven't really decided on which one work the best for the user, but I am assuming the other three appear grouped when you re-sort by state or any others...?

                    • 7. Re: Paging layout using portal?
                      philmodjunk

                      I would depend on how you implement this. With a list or table view, you'll essentially be performing the same find each time you change "page", but either constraining found set or omitting different records from it to pull up different groups of records. Sorting just the records currently on display is just a single sort step. Sorting so that data not currently visible might now be visible requires that you return to the original found set re-sort your records and then you'd return to page 1 as your original "pages" no longer have any meaning with the new sort order.

                      If you use a portal, you can use portal filtering to control which set of related records are currently visible, but changing the sort order will require a similar "start back at page 1" adjustment unless you choose for that sort change to only apply to the visible records.

                      • 8. Re: Paging layout using portal?
                        yuichim

                        Phil, I think I am going with the portal.
                        I have a layout with a portal with self-join relationsip.

                        Account::ID  x  Accounts2::ID 

                        In a layout, I am displaying a portal from accounts2 to show all the records. 
                        How would I go about to filter the records?

                        • 9. Re: Paging layout using portal?
                          philmodjunk

                          Do you know how to dynamically sort that portal?

                          How you filter the portal depends on the question you haven't answered: Will changing the sort order by clicking a column header resort just the currently visible records or will you have the portal return to Page 1 and resort the records so that records not visible when the header was clicked can be included in the new sort order?

                          Leaving Sorting out of that question.

                          Use this Relationship or  modified version of it: (Does not require FileMaker 11, BTW)

                          Account::gIDList = AccountsByPage::ID

                          gIDLIst should be a text field with global storage. It will store a list of Unique IDs from the portal table.

                          In your script,

                          Pull up all the records you want to show in the portal on a layout to AccountsByPage. Sort them in the order you want to see.

                          Use this script to bring up page 1 in your portal:

                          Set Variable [$$PageSize ; Value: 18 //specify the number of rows to your portal here]
                          Go To Record/Request/Page [First]
                          Loop
                             Set Variable [$IDList ; List ( $IDList ; AccountsByPage::ID ]
                             Exit Loop If [ValueCount ( $IDList ) = $$PageSize]
                             Go To Record/Request/Page [Next ; Exit After Last ]
                          End Loop
                          Set Field [Accounts::gIDLIst ; $IDList ]
                          Go To Layout [Accounts]//select the layout where you have the actual portal

                          Your "next page" script would look like:

                          Freeze Window
                          Go To Layout [AccountsByPage]
                          IF [Get ( RecordNumber ) < Get ( FoundCount ) //Make sure that you are not already on the last page of records]
                            Loop
                               Set Variable [$IDList ; List ( $IDList ; AccountsByPage::ID ]
                               Exit Loop If [ValueCount ( $IDList ) = $$PageSize]
                               Go To Record/Request/Page [Next ; Exit After Last ]
                             End Loop
                             Set Field [Accounts::gIDLIst ; $IDList ]
                          End IF
                          Go To Layout [Accounts]//select the layout where you have the actual portal

                          A "Previous Page" script would be exactly the same, but Go To Record would go to the Previous Record instead of the Next record.

                          • 10. Re: Paging layout using portal?
                            yuichim

                            Thanks for great info Phil!
                            I will implement the solution and will let you know :)