Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Sort Order (direction) info?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Sort Order (direction) info?

    when the behavior for a browse is set to sort on the title when clicked ... behind the scenes alpha does a quick_sort ... current_order_expn() only picks up the sort field and not the direction(ascending or descending). Is there an alpha function/method that provides the direction info. Interesting enough, that if you look at the browse object title, it show {sort_order} defined in the title ... so im assuming alpha knows the sort order somewhere .. unfortunately {sort_order} can only be used in xdialog ... is there anything in xbasic?

    Thanks!!

    Glenn

    #2
    Re: Sort Order (direction) info?

    Hi Glenn,
    I use this UDF:

    FUNCTION Sort_Embrws AS V (objectname AS C )
    'DESCRIPTION: use in Browse Events for objectname_TitleClick function
    dim shared sort_ord as c
    col_act = this.active(.t.)
    ' ":EE_List:BROWSE1"
    brws_nme = word(col_act,3,":")
    ' "BROWSE1"
    ' toggles sort_ord = objectname + 'a' or 'd'
    if sort_ord <> objectname+"a" then
    evaluate_template("topparent:"+brws_nme+".quicksortexplicit(""+objectname+"","A")")
    sort_ord = objectname+"a"
    else
    evaluate_template("topparent:"+brws_nme+".quicksortexplicit(""+objectname+"","D")")
    sort_ord = objectname+"d"
    end if
    END FUNCTION
    ' use in Browse Events for objectname_TitleClick function when you want the
    'columns to sort but also have an event for the column rows in which case
    'set browse property for columns as "Event" instead of "Sort"
    'use the name you gave the Column Title - not the object name for the field.
    Last edited by MoGrace; 06-08-2016, 06:54 PM.
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

    Comment


      #3
      Re: Sort Order (direction) info?

      This is the event that is added to Events by Alpha: Note that the bound field is TERMDATE but my column title is "Term Date" so the underscore is added.

      Code:
      FUNCTION Term_Date_TitleClick AS V (  )
      'DESCRIPTION: If the browse click behavior is set to call a user defined event, this method is called when the title row of the browse is clicked.
      Sort_Embrws("Term_Date")
      END FUNCTION
      Robin

      Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

      Comment


        #4
        Re: Sort Order (direction) info?

        Robin,

        Thanks you for a very cool technique .... the problem is, once you use the event for the title click to write code, the directional arrow that is maintained in the title goes away. That visual is kinda important to the end user.

        Glenn

        Comment


          #5
          Re: Sort Order (direction) info?

          Hi GLENN (sorry about that...),

          Have you looked at the XML definition of the browse? Or is this an embedded browse on a form?

          If I edit my UDF, I think I can get it to return the direction selected: 'A' or 'D' - is that what you want?

          If the action is changed from sort to event and you have added your own images for the browse, then Sort Order Icon will not be used (?) - which I think is some sort of internal function and not an actual icon, but I am probably wrong...

          I'm going to try it...
          Last edited by MoGrace; 06-08-2016, 07:13 PM.
          Robin

          Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

          Comment


            #6
            Re: Sort Order (direction) info?

            Right ..... if event not sort, the directional icon doesnt get used. I did look at the browse object quickly to see if I could throw the {sort_order} back in it, but it was there, just wasnt being displayed when using event. I was kinda hoping since Alpha can get the direction so easily with {sort_order}, there might have been some way of getting it in xbasic. One of those things that make you just scratch your head .. :)

            I have a form with embedded browse ... in that browse, user can sort any title. On the form there is a button, to run report .... the report is to print off what is in the browse, its current filter and its current order ... the code for the button uses current_order_expn() to set the order for the report, but it doesnt pick up the direction. I was hoping to have a way to query the current direction and then in the code to run report, i could apply invert() to the current order if the browse was in descending order.

            Comment


              #7
              Re: Sort Order (direction) info?

              Well if you are going to let the user sort the browse then he must suffer his report in that order - no? Otherwise he will have to cancel and resort again.

              Makes sense to me. Sometimes you just gotta let users learn by themselves!

              Since this is an embedded browse, I changed my UDF to return the column_title name + 'a' or 'd' - would that help?
              Robin

              Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

              Comment


                #8
                Re: Sort Order (direction) info?

                I do want the report to sort according to sort selected in the browse .... but cant because i dont have sort direction info. So user thinks they are clicking the column to sort data in descending order and then when they run report, it comes back in in ascending because current_order_expn doesn't pick up direction or sort .... this could be confusing. I may have to completely control the code and the status by using your method, but i wouldn't use quick_sort .... i would do a query with invert(). This would allow current_order_expn() to report on the true order of things. It seems Alpha always gives me the taste of a simpler way .... but when it comes down to it, have to write the long code anyway .... :)

                To be honest, this could be considered a bug ..... current_order_expn() should know when the data is in descending order and modify the expression to include invert() for descending order. Oh well .......

                Thanks for your help and the ideas Robin ......

                Glenn

                Comment


                  #9
                  Re: Sort Order (direction) info?

                  I usually have 2 versions of common reports. One I call Quick_reportname gets the filter from the current selected record on a form. The other is more 'generic' in that no filter or order is defined in the report at all. This allows me to call the report and add what ever filter or order I need. So if you are calling this generic report with an order expression of 'current_order_expression()' and a filter of 'current_filter_expression(), it should give you what the form is displaying (assuming of course we are speaking of the same table and set...)

                  Is this what you are doing?

                  report.preview(reportname,"current_filter_expression()",current_order_expression()")
                  Robin

                  Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                  Comment


                    #10
                    Re: Sort Order (direction) info?

                    Robin,

                    Pretty much ... except the functions are current_filter_expn() and current_order_expn() ... and everything would be great if current_order_expn() would recognize the quick sort direction, but it doesnt. example ... you have an embedded browse with a field call cdate .... you click on cdate and it orders it in ascending order ... if you pass current_order_expn() to the button to run report current_order_expn() would give you "cdate" ... all is good. if you click on the title for cdate again, now it is sorted in descending order .... current_order_expn() would still pass "cdate" because it doesnt recognize the quick sort direction of descending .... why?? ... couldnt tell you. Thats why im almost thinking this is a bug.

                    Comment


                      #11
                      Re: Sort Order (direction) info?

                      I take it the form is based on a set then? Because if it is based on one table the topparent pointer should show the current sort.

                      You could always do the button trick in place of browse column titles. Each button would toggle the sort you want and capture the sort order into a shared variable. More trouble to design but definitely gives you more options using a button. You can even toggle the bitmap displayed.

                      (sorry about the syntax errors - I didn't look up the actual function names)
                      Robin

                      Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                      Comment


                        #12
                        Re: Sort Order (direction) info?

                        Nope .... single table. quick sort for some reason does not update current_order_expn() with the sort direction. I will probably use event and control the status and the order using query rather than the quick sort. Hey, at least i'm getting more practice coding ... :)

                        Comment


                          #13
                          Re: Sort Order (direction) info?

                          I just did a quick filter on a one table form w/ embedded browse and used the file menu to preview the form as a report. Which of course worked fine. Are you using the AS genie? Something is definitely askew here.
                          Robin

                          Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                          Comment


                            #14
                            Re: Sort Order (direction) info?

                            Robin,

                            If you just creates quick form with embedded browse ... set the click behavior for the browse to sort (in browse properties) ... put a button on the form to open debug ..

                            Then load form .... click on title to sort ascending .... click debug button ... type debug expression current_order_expn() .... then do the same after clicking on title again (descending) .... you will see that order expression stays just the field (which defaults to ascending) .... current_order_expn() never gets the direction for descending (which would have to be converted to invert() to be saved as an expression .....

                            Comment


                              #15
                              Re: Sort Order (direction) info?

                              Robin,

                              Ran through the same test you did, but when i clicked on title to put it in descending order the report printed, but still in ascending sort order ... I looked at the code it generated it it to is using the current_order_expn() which never seams to pick up the descending order .... hmmmmmmm

                              Comment

                              Working...
                              X