3 Replies Latest reply on Jun 19, 2014 8:26 AM by philmodjunk

    Sort Portal Records via Portal Header

    AnthonyPaliseno

      Title

      Sort Portal Records via Portal Header

      Post


           Title

           Anyway I can sort my portal records via the label above the portal (as a clickable button)

            

        • 1. Re: Sort Portal Records via Portal Header
          philmodjunk

               Do you mean that you want to sort the same portal into different orders depending on what button is clicked?

               Yes that is possible and there are two different ways to do it.

          • 3. Re: Sort Portal Records via Portal Header
            philmodjunk

                 The simplest method to describe doesn't actually change a portal's sort order. It uses a tab control to create the illusion that the sort order was changed. I'll make this a two sort order example and leave it up to you to generalize this to more sort orders if you find that you need to:

                 Say you have a portal with a Name field and a Date field. If the user clicks Name, the portal rows should display in alphabetical order on the name field. IF the user clicks Date, the portal should display the portal rows with the most recent date at the top of the portal.

                 Add A tab control to your layout with two tab panels. Label the first panel "Name" and the second "Date".

                 Set up your portal on the Name panel and specify a sort order in Portal set up that sorts your records by the Name field in ascending order.

                 In the Inspector's position tab, click the units until pts or pixels show. With the portal selected, make note of the Top and Left box values. Now select and copy the portal and the fields in the portal row.

                 Switch panels to the Date Panel and paste your portal into this panel. Adjust the position of this portal until it's Top and Left values match those of the first copy on the Name panel. This is to keep the portal from "jumping" when you click back and forth between tab panels.

                 Open portal setup for this copy of the portal and change the sort order to be by Date in Descending order.

                 Now enter Browse mode and test by clicking the Name and Date tabs of the tab control.

                 The result that you see on your screen may be all that you need do, but if you want to do a bit of "sleight of hand" trickery, you can make the tab control disappear and make it look like you have a single portal with two buttons that change the sort order.

                 First, select each tab panel in turn while in layout mode and use the Name box in the Inspector to assign an object name to each tab panel. (You typically have to click the tab control twice--once to select the tab control and once to select the panel.)

                 Now add two buttons that use Go to Object to select one of the two tab panels by object name.

                 The last step is to assign transparent fill and border values to the tab control to make the tab control disappear.

                 What's left are two buttons for selecting a sort order and what appears to be a single portal.

                 PS. The other method for controlling sort order in a tab control uses a complex unstored calculation field that returns a text form of the value of different fields depending on the value of a global field or variable. The buttons then control the sort order by changing the value of this global field or variable. This method is tricky as you have to produce text versions of date and number values that still sort correctly even though the caclulated value is text not a date or number.