4 Replies Latest reply on Mar 5, 2013 4:52 PM by vlight

    Sorting columns in List view using Script attached to Column label

    vlight

      Title

      Sorting columns in List view using Script attached to Column label

      Post

           In the FM 11 Training Series, in the sample Bonsai file, the list views have a great feature where you can click on the column labels, and the all the columns will sort in an alternating ascending/descending order, and is accomplished (in part) through a great Script that is attached to the column label.  But there must be something else that i'm missing for this to be accomplished!  What is it? How does the script actually know which column of data to sort (as the names of the script parameters and the globals in the script do not match up with the actual field name in the column) ??  I would like to duplicate this technique in my files!

        • 1. Re: Sorting columns in List view using Script attached to Column label
          philmodjunk

               Did you look at the scripts performed when those buttons are clicked? (The column heads have been setup up as buttons).

               I don't have that file at my fingertips, but I seem to recall that the scripts use a global variable to keep track of the current sort order so that if the current value in the global field is "ascending", it sorts in descending order and sets the variable to "descending". If the value is "descending" the opposite takes place.

          • 2. Re: Sorting columns in List view using Script attached to Column label
            vlight

                 Yes, what you say is correct.  But what i can't figure out is this:  How does the Script know which actual field/column to sort?  Because, as i said earlier,  the names of the script parameters and the global variables do not match up with the actual field name in the column to be sorted.  

                 For example, the actual field name to be sorted is "NameFirst" ;  the column label (that has the script attached) says "First Name" ;  the script parameter says "firstname" ;  and the global variable is called "$$Sort_CustomerFirstName" .   

            • 3. Re: Sorting columns in List view using Script attached to Column label
              philmodjunk

                   That's controlled by the If steps.

                   Each part of those steps has a different sort records step and each such step checks the value of the script parameter to determine which sort to perform.

              • 4. Re: Sorting columns in List view using Script attached to Column label
                vlight

                     Thank you.  By going into each "Sort Records" step within each of the  "IF" and "Else" steps, i see that THAT is where i make the change so it reflects which of my own fields i want it to sort.

                     The problem i have discovered is that my mind's eye was focusing on the changing script parameters (which is obviously important) and the global variable names,  and i was completely glossing over having to look into each "Sort Records" step.   Many thanks.