8 Replies Latest reply on Jan 18, 2012 3:32 PM by philmodjunk

    Sorting List Buttons

    brentjohn

      Title

      Sorting List Buttons

      Post

       

      I am creating a list (with “Account No.”, “Type”, Account Name” as the column headers), and would like for the following to occur:

       

      1. When the button to sort the list is clicked, I would like for that button to change colors.

      2. I would like for an Arrow to appear within the button (to the ride or left side) to indicate whether the sort is ascending or descending.

       

      I have spend most of the weekend searching for these wishes.  Any help would be greatly appreciated.

        • 1. Re: Sorting List Buttons
          philmodjunk

          Assuming that you are using a list view layout, not table view:

          Define a global field: $$SortFieldName. When a user clicks one of these sort buttons, set this variable to the name of the field being sorted. Use this field in conditional format expressions to change the fill color of the button (and or the text color if you wish) when the name of the button's field matches the value in this global field.

          Define a second global field: $$Ascending

          In your script use: Set Variable [$$Ascending ; value: Not $$Ascending ]

          To toggle the value between true and false. You can now use the values in $$ascending and $$SortFieldName within your buttons' scripts to sort the data to match the values assigned to these two global fields.

          • 2. Re: Sorting List Buttons
            brentjohn

            PhilMod,

            Thank you much for your response.

            I tried doing what you said – see attached – but for some reason I am not able to get to the end result.

            Any additional help would be greatly appreciated.

             

            • 3. Re: Sorting List Buttons
              brentjohn

              PhilMod,

              Sorry the attachments did not post.

              1. I created a global field: $$SortFieldName.

              2. I clicked on “Button Set-Up”, “Set Variable”, Set Variable Option: Name “$$SortFieldName”, Value: Field being sorted.

              3. Conditional Format: “Customer Info::Account_No = Customer Info::${$$SortFieldName}”.

               

              Nothing is happening?

              • 4. Re: Sorting List Buttons
                philmodjunk

                As each button will need to do multiple things (update global variables AND sort the data), you will need to write scripts that do this and use the Perform Script button setting. (Many developers limit all buttons to only this one setting so they can better manage development.)

                Here's a typical script that could be used with all your sort buttons:

                Set Variable [$$Ascending ; value: Not $$Ascending ]
                Set Variable [$$SortField ; get ( ScriptParameter ) ]
                If [$$SortField = "Name" ]
                   If [$$Ascending]
                       Sort Records [Restore ; no dialog ] // specify a sort on the name field in ascending order
                   Else
                       Sort Records [Restore ; no dialog ] // specify a sort on the name field in descending order   
                   End If
                Else IF [$$SortField = "Date"]
                    If [$$Ascending ]

                and so forth for each field on which you want to sort on your layout.

                In button setup, use the option script parameter to pass the name of a field as the parameter ("Name" or "Date" in this example script.)

                • 5. Re: Sorting List Buttons
                  brentjohn

                  PhilMod,

                   

                  That works.  Thank you much for your help.

                  • 6. Re: Sorting List Buttons
                    philmodjunk

                    Note that conditional formatting can be set up that reference these two global fields so that you have a visual indicator of which sort field is selected and what sort order is currently specified. That's the only reason to set up $$SortField as a global variable like I did, so that the value in it will persist after the script is run and a conditional format can then use it.

                    • 7. Re: Sorting List Buttons
                      brentjohn

                      PhilMod,

                      That worked as well.  again, thank you much for your help.

                       

                      I do have another question, it is possible to save several custom colors?  When I create a custom color and save it, then when I create a different custom color and save it, the first custom color is gone.  I would think there is a way, considering 16 "boxes" are available.

                      • 8. Re: Sorting List Buttons
                        philmodjunk

                        Not as far as I have figured out. The color picker on windows seems a bit buggy to me. I have figured out that once I've given a layout object a custom color, I can use that object to get the custom color back--which can be useful when coordinating the color of different objects.