Ron Cates Posted May 2, 2012 Posted May 2, 2012 Hi All After helping someone adjust a portal sort technique they were trying to add to thier file and due to the fact that i am working on a solution that will need multiple instances of a portal sort technique myself, I was inspired to work up the current technique I use and expand it and make it dynamic so that the same script can be used for multiple portals throughout a file. I also felt that many of the options available out there were overly complicated in thier use of custom functions and other complicated coding. I am proud to say that I believe I have come up with something quite nice that is simple to add to an existing file. It uses four calc fields and passes multiple script parameters to allow for a very simple script that is made up of dynamic coding that needs no editting for use with multiple portals. This first file is a basic implimentation that allows for clicking a column header to sort ascending and again to reverse direction. I am currently working on extending the capabilties to include shift clicking to add a second sort field. That file will be available soon.. This is the first time I have put together something that I think might possibly be worthy of free distribution for others to use. I would love to hear some opinions from some of the power houses here on the forum as to wether I should try to get it out there. And it is probably in need of a few tweeks before that anyway. I am on windows and have not tested this on Mac so if someone could let me know if there are any platform issues I would appreciate it. It converted just fine to FM12 so if you're looking for a FM 12 file, just download and convert it. The technique I started with was pieced together a while back from a combination of sources so I'm afraid I would be hard pressed to extend credit to anyone by name. I will amention that the use of a single merge variable to display the sort indicators was inspired by one of Matt Petrowski's videos at www.filemakermagazine.com . Looking forward to the feedback Updated File on 5/4/2012 to include fix for negative numbers and decimals Dynamic Portal xSort.zip
comment Posted May 2, 2012 Posted May 2, 2012 I do believe comment was responsible for the calculations used in the sort fields. I don't think so, at least I hope not. The problem is much more complex than what your file shows. Just as an example, add some negative numbers and fractions to the mix and see how it breaks.
Ron Cates Posted May 2, 2012 Author Posted May 2, 2012 Hi comment. I will be the first to say that it is not the end all of portal sorting techniques. I was mostly just trying to simplify the implimentation of an existing technique. That being said. I do know there are some limitations like chinese charachters and as you pounted out, negitive numbers and fractions. I remeber that you gave some assistance with the calcs at the time and pointed out those short comings then as well. So, sorry I probably should have phrased it differently than to say that you were responsible for them. I will edit the post My goal mostly was to make it more portable and dynamic.. Do you think there is any way to overcome the negative and decimal short comings?
comment Posted May 2, 2012 Posted May 2, 2012 I wish the forum's search was working properly so I could point to some previous posts on the subject. In a nutshell, there is no way to make it perfect. If you choose to accept some limitations (e.g. numbers within a range of ±10^-9 to 10^9 and Spanish text sorting rules only), then it can be worked out with a reasonable hit on performance (provided the number of child records is reasonable, too). iMHO, placing several pre-sorted portals inside a tab control object is a much better solution. See also an entirely different approach here: http://www.fitchandf...portal-sorting/
Ron Cates Posted May 2, 2012 Author Posted May 2, 2012 I remember a post quite a while ago that is refered to from time to time where there was a long debate on tab vs calculation. I opted then to go with this type of technique because of the usual argument that maintaining multiple tabs can get quite tedious, especially when adding new columns or simply adjusting the existing ones. I went with the calc option knowing the limitations and realizing that I would not be able to use it under those cercumstances. So far I haven't run into those situations and I have been very happy with it. some limitations (e.g. numbers within a range of ±10^-9 to 10^9 Does this mean that the negative number and decimal problems can't be solved? provided the number of child records is reasonable, too Agreed. I believe using a portal to display large sets of records is not advisable for many reasons. At least that's the guideline i live by. But i guess that would make this technique a little less attractive for a list view. See also an entirely different approach here: http://www.fitchandf...portal-sorting/ I have seen that technique recently and a couple others that are similar. One of the reasons I started on this project came from helping someone with an implimentation of one. I was ultimately just trying to come up with an easier option to impliment and the challenge to myself was to make it portable and dynamic which was actually my point of pride in the file I created :)
Fitch Posted May 2, 2012 Posted May 2, 2012 Nice job, Ron. Maybe Kevin Frank would be someone to credit -- he uses a similar calculated field for sorting. (And had similar issues with negative numbers, which he looks at in a later blog post.) Kevin and I had a good discussion about portal sorting. This is one of those areas where there is no single "correct" way to implement. There are tradeoffs in performance, portability, and maintenance. So far, I still prefer my method and he prefers his.
comment Posted May 2, 2012 Posted May 2, 2012 some limitations (e.g. numbers within a range of ±10^-9 to 10^9 Does this mean that the negative number and decimal problems can't be solved? No, but solving for numbers larger than 10^9 or smaller than 10^-9 (positive or negative) is much more complex and as a result, prohibitively slow. The thing that cannot be solved by any calculation is sorting text by a specific language - e.g. English vs. Unicode.
Ron Cates Posted May 2, 2012 Author Posted May 2, 2012 Thanks Fitch. The debate on portal sorting rages on. Tabs, calculations and now the virtual list technique ( for lack of a better name). In no way am I presenting this as the best portal sorting option. Just another implimentation of one of the options. As i said, my focus was mostly on making it dynamic for use with multiple portals and easy to drop into another file. I know for me some of the other options i explored earlier on were very intimidating in thier complexity and I struggled to get them into my file. for a long time i didn't understand custom functions or even how to import one. Even now implimenting the virtual list technique looks very daunting, It took a lot of fumbling to get this technique working originally in my solution and much longer before i actually understood what it was doing. So my efforts, besides making it easier for me to add sorting to new portals in my db, were mostly aimed at those who might have the same struggles i did.
Ron Cates Posted May 3, 2012 Author Posted May 3, 2012 So I guess I need to find a calculation that won't break on negative numbers and decimals. Any help would be appreciated..
Ron Cates Posted May 3, 2012 Author Posted May 3, 2012 Nice job, Ron. Maybe Kevin Frank would be someone to credit -- he uses a similar calculated field for sorting. (And had similar issues with negative numbers, which he looks at in a later blog post.) His blog definitely describes the same calculated technique so I'm sure the one i use was at least based on the same technique as his. The blog post is dated last April ( posted on my birthday in fact. Lol ). I had this in place some time before that, but that's not to say that it didn't in some part involve his contribution or originate from him. In fact, I would have loved his blog at the time as he does a great job of explaining exactly what is going on with this technique and how it does what it does. When I first implimented it I really didn't grasp it all that well and could have benefitted greatly from his explaination. Combing through his sight now to find the post where he talks about the negative number issue..
Ron Cates Posted May 4, 2012 Author Posted May 4, 2012 Well I think I may have fixed the decimal issue. I seperated the whole number out and padded it with zeros first so that they were all the same length. Then I tacked the decimal back onto it. So the results look something like this. 000000000000000.2 000000000000000.255555551 000000000000124.5 000000000000125.67 So far the testing i've done seems to show this to work.
Ron Cates Posted May 4, 2012 Author Posted May 4, 2012 Now as for the negatives I switched them to positive and have them populat in the oposite field so that they sort in the opposite direction. Inspired by a method explored by Kevin Frank in his later blog addressing negative numbers. Reuploaded the file to the first post..
Ron Cates Posted May 4, 2012 Author Posted May 4, 2012 And here's the new one with the option to hold down shift to add a second column to the sort. :) Dynamic Portal xSort2.zip
Recommended Posts
This topic is 4585 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now