1 Reply Latest reply on Sep 8, 2011 4:03 PM by philmodjunk

    Sorting/filtering

      Title

      Sorting/filtering

      Post

      Hi

      I have a small problem with my filtering etc. If you see my attachement then this may be a little clearer. What I want to end up with is  a system where the user can click on the buttons labelled All sales, quotes, orders etc, which will filter the records below to only show records that the 'order type' field displays the relevent information (Anything, Sale, order, invoice - not worrying about the open/closed invoices or credits at this juncture). Once these records have been filtered, I would like some way for the user the then click on any of the titels to then sort the displayed results. For the 'Date created' I would like some sort of toggle command with an  up/down arrow showing to the right of were it says 'date created' ( i have the graphics for the arrow), so that the user can sort the results from the filtered records by 'date created'. And the job number by number, the Name, by surname or company name (alphabetically), status alphabetically to (the reuslts will be open, confirmed, closed etc).

      I  am aware that I have supopied not a lot of information so do ask any thing rewuired. The Layout is called sales list, the table is Invoices. Ignore the buttons at the top! (Contacts, sales purchases etc)

      screen-capture.png

        • 1. Re: Sorting/filtering
          philmodjunk

          The first part is simply implementing a series of scripts for each button that perform the needed finds by specifying criteria appropriate to the requirements for that button.

          Here's an example where all records where Order_Type = "Sales" will be found:

          Enter Find mode [] //clear the pause check box
          Set field [Invoices::Order Type ; "Sales"]
          Set Error capture [on] //keeps dialog box from interrupting your script if no records are found.
          Perform Find []
          Sort [no dialog ; restore ] //specify a sort order you want to appear initially.

          For your click a column head to sort feature, you can use button setup to turn each column heading into a button and each can perform it's own sort script.

          If you want to toggle between ascending and descending sort order options, you can have your script use global fields or variables to keep track of the current sort order.

          That produces a script like this:

          #Sorts by Date Created in opposite of current sort order if sorted by date.
          If [$$SortField = "Date Created" and $$SortOrder = "Ascending" ]
              Sort [no dialog ; restore ] //specify sort on Date created in descending order
              Set variable [$$SortOrder ; Value: "Descending"]
          Else
              Sort [no dialog ; restore ] //specify sort on date created in ascending order
              Set variable [$$SortOrder ; Value: "Ascending"]
              Set Variable [$$SortField ; Value: "Date Created"]
          End If

          Note, if found set is sorted on any other field, the sort defaults to ascending order.