FileMaker® Pro Tip-n-Trick: Smart & Simple Column Sort
By: RJ Carroll
One of the most-requested features from FileMaker Pro developers is a one-click simple column sort. Trying to sort out how to sort can be a tricky business. The typical way to implement column sort from list-view is by using buttons above each column. First, the user calls a script by clicking on a field name in the column header. Usually, the script includes a number of hard-coded “Sort Records” steps. Then, the script decides which field to sort and how from a series of If/Else If steps. Each order of each potential field would require its own script step.) Scripts like this leave a lot of things to change if you add or delete fields. (They also leave a lot of code to maintain in general.) Before FileMaker introduced “Sort Records by Field”, this was basically the only sort of way to do it (pardon the pun).
Sort Records by Field
A simpler approach is to leverage the power of “Sort Records by Field.” One advantage of “Sort Records by Field” is that, unlike “Sort Records,” you can leave the field unspecified and use the context of the currently active field. It also eliminates the need for extensive “If…Else” branching logic and hard-coded sort orders in the sorting script. The only issue with using “Sort Records by Field” this way is that when a user clicks a button on the layout, the user isn’t actually in the field when the script gets called. Most users would expect to click a button (such as the field’s name) in the column header to call a sort script, but since clicking a button takes you out of the field, it won’t work. So what do you do?
From Button to Trigger
One clever workaround: place copies of the fields you want for sorting in the header and use an OnObjectEnter trigger to invoke the script. This eliminates all need for script parameters and branching logic altogether. It also allows for powerful one-click column sorting. Just style those fields to look like “sort buttons”. Now have an elegant method for sorting by columns that is simple and easy. It is also manageable, easy to maintain as your solution changes. Check out this implementation by downloading our demo file. I think you’ll find it’s remarkably simple with this technique to get all your sorting quickly sorted out.
Aside from providing excellent customer service, our goals are to use these technologies to intuitively automate your organization’s data solution needs seamlessly and flawlessly across the web, mobile, and desktop platforms. Contact Excelisys today for a free estimate and consultation regarding your business software automation needs @ 866-592-9235.Excelisys, Inc. is an independent entity and this web site/information/blog post has not been authorized, sponsored, or otherwise affiliated with FileMaker, Inc. FileMaker is a trademark of FileMaker, Inc., registered in the U.S. and other countries.
After completing a graduate degree in 2008, RJ spent six years in higher education as a student affairs professional serving as his staff’s point man for all things tech. He moved the process for staff recruitment to a custom PHP-based online site which incorporated social media and Google Drive integration. His foray into FileMaker Pro development started as an attempt to wrangle multiple disparate paper-based processes into an accessible reliable solution that his staff could use to track information in student housing. RJ began creating FileMaker Pro solutions to improve operations for his institution, which included mobile solutions running on iPhones and iPads with FileMaker Go. He integrated FileMaker Pro solutions with existing SQL Server databases and an Oracle-based student information system.
Before joining Excelisys, RJ worked as a freelance developer for several years, becoming a Certified FileMaker Pro Developer and serving clients in a range of industries, including education, tourism, entertainment and manufacturing. RJ is an SQL whiz (so he says), specializing in connection of FileMaker Pro solutions with web apps and platforms using RESTful APIs. His background includes experience with a diverse range of software platforms, from Adobe CS to VBScript; he is particularly proud of his keen “Google-fu.” Currently, RJ is learning Ruby on Rails and experimenting with hybrid Rails/FM solutions.
As a recovering philosophy major, RJ is deeply interested in “meta” everything, like metaphysics, meta-ethics, and–most recently–meta-programming. He resides in Philadelphia and is a huge fan of urban life. When he isn’t poised above his keyboard, RJ likes to learn languages, write iambic pentameter, bike around the city, pretend to play rugby, eat adventurously, and cut his own hair.
Welcome to eX-Cetera, our little corner of the website where you will find the latest tips, tricks, and news relating to our company and our world of custom database software and web application development.