Jalz Posted July 1, 2006 Posted July 1, 2006 Is there a way of obtaining whether a recordset is sorted in acsending or descending order? I've looks through the list of the Get commands, and cant seem to find it. The reason I want to know this is because I have navigation script which allows the users to go to the next or previous records. When the records are sorted on a numertic field, I tend to use decending (as I want the highest number at the top), and at this point the navigation buttons work backwords. Thanks for any advice
Ender Posted July 1, 2006 Posted July 1, 2006 There's no function for this. If your sorts are scripted, you can set the sort choice in a global.
Jalz Posted July 2, 2006 Author Posted July 2, 2006 Thanks Ender, As I've got everything in one file, I think I'll script it in a global variable. I dont fancy creating a extra field. Its a pity theres only get(SortState), it would be much more useful if you could get the order nand possibly the field name without all these work arounds.
Ender Posted July 2, 2006 Posted July 2, 2006 Well, it's not as simple as that. Suppose you're sorting by more than one field, maybe sorting by Date (Descending) then Name (Ascending). Any function to disect this sort state will necessarily have to parse out the field and its ascending/descending/value list choice. If you're doing it by your own method, you can ignore the first sort field in some circumstances, or ignore the second sort field in others. For example, if you have a list of Contacts that has buttons to sort it by: 1. Name Last, Name First 2. Company, Name Last, Name First 3. Date of Last Contact, Name Last, Name First 4. Sales Person, Name Last, Name First With this, the actual sort options are somewhat complex, but for our purposes, it's only necessary to know if they are sorted by "Name", "Company", "Date", or "Salesperson", and Ascending or Descending. So I see two globals for this, the Sort_Field and AscendingDescending_Choice. The sort script would then have the 8 sort options, with branching to use the correct one based on the script parameter (passed from the button) and the two globals: If [ get(scriptparameter) = "Name" ] If [ $$Sort_Field = "Name" ] If [ $$AscendingDescending_Choice = "Ascending" ] Sort [ by Name Last (Descending), Name First (Descending) ] Set Variable [ $$AscendingDescending_Choice ; "Descending" ] Else Sort [ by Name Last (Ascending), Name First (Ascending) ] Set Variable [ $$AscendingDescending_Choice ; "Ascending" ] End If Else Sort [ by Name Last (Ascending), Name First (Ascending) ] Set Variable [ $$AscendingDescending_Choice ; "Ascending" ] Set Variable [ $$Sort_Field ; "Name" ] End If Else If [ get(scriptparameter) = "Company" ] ...
Oldfogey Posted July 4, 2006 Posted July 4, 2006 Wouldn't it be simpler to change the navigation buttons when the sort is executed? In the sort script, include set $$SortHold; "A" then for the button(s), Script - Navigate(parameter = $$SortHold) if (Get(ScriptParameter) = "D" Go to Record [Previous] Else Go to Record [Next] end if Or am I missing something (again)?
Ender Posted July 4, 2006 Posted July 4, 2006 Hmm, your solution brings to question Jalz' statement: When the records are sorted on a numertic field, I tend to use decending (as I want the highest number at the top), and at this point the navigation buttons work backwords. What does this really mean? If the records are sorted descending, like: 89 45 23 11 And the user is on "45", then what is Jalz doing for navigation that's backwords? Certainly Go to Record/Request/Page [ Next ] would bring up "23". Isn't this what it should be doing? If not, what would be the point of sorting descending? Jalz, what the heck is going on over there? :qwery:
Recommended Posts
This topic is 6720 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