1 Reply Latest reply on Aug 20, 2012 6:34 AM by philmodjunk

    Scripted List View Sort Ascend Descend - Advice Requested

    davidanders

      Title

      Scripted List View Sort Ascend Descend - Advice Requested

      Post

      Found this during a Google today...
      http://www.phillyfilemaker.org/index.php/2011/03/we-can-sort-it-out/
      There is a demo download  -  http://www.phillyfilemaker.org/wp-content/uploads/2011/03/SortEx.zip

      I'll wait while you read it,,, dumm de dum....

      Similar ascending / descending sorting behavior to that found in most email clients.

      (The author credited this thread post by Comment)  -  http://fmforums.com/forum/topic/53338-sort-script/
      with this demo download  -  http://fmforums.com/forum/index.php?app=core&module=attach&section=attach&attach_id=9206

      The download from Philly seems straight forward, but I am confused.

      This is the Main Remember Previous Sort & Sort Script

      #Deterimine the Current Sort Order
      Set Variable [ $$SortOrder; Value:Case(
            Get(ScriptParameter) = $$SortField; not $$SortOrder) ]
      If [ not $$SortOrder ]
           #SORT ASCENDING

           If [ Get ( ScriptParameter ) = "ID" ]    
                Unsort Records
           Else If [ Get ( ScriptParameter ) = "EventType" ]    
                Sort Records [ Specified Sort Order: Field Trips::EventType; ascending ]    
                [ Restore; No dialog ]
           Else If [ Get ( ScriptParameter ) = "Date" ]    
                Sort Records [ Specified Sort Order: Field Trips::Field Trip Date; ascending ]    
                [ Restore; No dialog ]
           Else If [ Get ( ScriptParameter ) = "Contact" ]    
                Sort Records [ Specified Sort Order: Field Trips::Contact; ascending ]    
                [ Restore; No dialog ]
           End If
      Else
           #SORT DESCENDING

           If [ Get ( ScriptParameter ) = "ID" ]
                Sort Records [ Specified Sort Order: descending ]    
                [ Restore; No dialog ]         
           Else If [ Get ( ScriptParameter ) = "EventType" ]         
                Sort Records [ Specified Sort Order: Field Trips::EventType; descending ]
                [ Restore; No dialog ]
           Else If [ Get ( ScriptParameter ) = "Date" ]
                Sort Records [ Specified Sort Order: Field Trips::Field Trip Date; descending ]
                [ Restore; No dialog ]
           Else If [ Get ( ScriptParameter ) = "Contact" ]
                Sort Records [ Specified Sort Order: Field Trips::Contact; descending ]
                [ Restore; No dialog ]
           End If
      End If

      #REMEMBER THIS SORT
      Set Variable [ $$SortField; Value:Get(ScriptParameter) ]
      // Set Variable [ $$SortBanner; Value:"Sort: " & $$SortField &"; " &
      If($$SortOrder=1;" Descending" & Char( "&#9660") ;" Ascending" & Char( "&#9650") ) ]
      Set Variable [ $$EventTypeSort; Value:
           Case(
                $$SortField = "EventType" and $$SortOrder=1; Char( "&#9660") ;
                $$SortField = "EventType" ; Char( "&#9650");"" ) ]
      Set Variable [ $$DateSort; Value:
           Case(
                $$SortField = "Date" and $$SortOrder=1; Char( "&#9660") ;
                $$SortField = "Date" ; Char( "&#9650");"" ) ]
      Set Variable [ $$ContactSort; Value:
           Case(
                $$SortField = "Contact" and $$SortOrder=1; Char( "&#9660") ;
                $$SortField = "Contact" ; Char( "&#9650");"" ) ]

      There is mention of global arrow fields? no evidence of them. Aside from the unicode in the script. Why not use Arial? It has the arrows.

      Small scripts are apparently needed for each column sort in the List View.

      1] On List View Eventtype Column is labelled "Trip Title <<$$EventTypeSort>>" buttoned to script

      Sort by Field Trip Title
      Sort Records [ Specified Sort Order: Field Trips::EventType; ascending ] [ Restore; No dialog ]
      Go to Record/Request/Page [ 1 ] [ No dialog ]

      2]  On List View Column Title for "Field Trip Date" is labelled "Date <<$$dateSort>>" buttoned to script

       

      Any clues, directions, evaluations, or advice would be appreciated.

      Thanks

      David Anders
      The Computer Guy, Seattle

        • 1. Re: Scripted List View Sort Ascend Descend - Advice Requested
          philmodjunk

          There is mention of global arrow fields?

          Without downloading the file--just reading the above script, I think they meant global variables as the script sets several as visual indicators of the current sort order.

          Why not use Arial?

          Developer preference? Developer didn't know about arial arrows? (Kinda hard for anyone but the creator to answer a "why" question of that sort.

          This all looks rather familiar. Seems like one or more starter solutions has done something similar.