• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 16. Working with Portals > Dynamic Portal Sorting

Dynamic Portal Sorting

Developers often place column labels above portals, and one of the first things we've seen users do with a newly minted database is click those ever-so-tempting column headers expecting them to sort. As discussed previously in this chapter, you can sort portals either at the portal level or at the relationship level. One of the more common requests we get as developers is to allow users to sort by whatever column they wish. Unfortunately, there's no way to programmatically define by which field a portal sorts. There is, however, a method for dynamically sorting a portal.

Using a calculation field, you provide FileMaker with the data by which you want a portal sorted. You need to create two new fields for your database: a control field, gSortPref, to hold the name of the field by which you want to sort, and a field for the actual sorting, sortCalc. We suggest you place sortCalc in the same table in which the rest of your portal fields sit. Your control field serves as a mechanism for choosing sort order. There are multiple ways to allow the user to change the values in it: You can use a value list, set by script when a user clicks on a column header, or perhaps a script available in the Scripts menu. However this field is managed, it's the end result that is important. Your sortCalc field depends on it. Here's an example of how sortCalc might be defined:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint