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

help with ajax callback

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

  • help with ajax callback

    I have a dialog component that has 2 sets of address data.

    I setup a function to calculate the distance between the 2 addresses,
    but now I'm lost as to how to A. pass the lon/lat data to the function,
    and B. how to get the result into the desired control.

    Any help would be appreciated.


    Gregg
    Gregg
    https://paiza.io is a great site to test and share sql code

  • #2
    Re: help with ajax callback

    You didn't say whether you were using a repeating section or not, but I had to really wrestle with getting and setting values in a repeating section. A sample of accomplishing it is below. When setting a value, you do not need to use the [i] to identify the row (for some reason). If not a repeating section, then you just get your data with e.dataSubmitted.fieldName (without the [i] part). There is quite a bit of 'quick help' info about this in the Server Side dialogValidate and afterDialogValidate events.

    Code:
    function JOB_CODE_OnChange as c (e as p)
    
    'Per Alpha:
    'The e.repeatingSectionInfo[] array will have these properties for each entry:
    ' - .activeRow - the row in the repeating section that had focus when the Dialog was submitted
    
    'get the active Row from the e.repeating section so code will only be done on the active row.
    'It is returned as a character so then need to convert it to a number for the i value after e.dataSubmitted.fieldName[i].
    'Note that the 1 in the square brackets after e.repeatingSectionInfo refers to the first repeating section.
    'If there were more repeating sections (or containers), the 2nd one would have a 2 between square brackets
    'and 3rd repeating section would have a 3, etc.	
    
    dim activeRow as c = e.repeatingSectionInfo[1].activeRow 
    dim i as n
    i = convert_type(activeRow,"N")
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    if e.dataSubmitted.JOB_CODE[i] = "H" then
    	e._set.JOB_SUB_CODE.value = 0
    	e._set.JOB_MARGIN.value = 0
    else
                open connection and do some other stuff that requires a callback to the server
    
    end function
    Carol King
    Developer of Custom Homebuilders' Solutions (CHS)
    http://www.CHSBuilderSoftware.com

    Comment


    • #3
      Re: help with ajax callback

      Hi Carol,

      I am probably not doing a good job of describing things here.
      The dialog in question is an order entry screen.
      The operator will need this information to complete
      the order.

      Can this be done without submitting the dialog
      for validation ?
      Gregg
      https://paiza.io is a great site to test and share sql code

      Comment


      • #4
        Re: help with ajax callback

        Yes, my example function is called via an Ajax Callback from the OnChange event of my JOB_CODE field (NOT from the submit events)

        It is a little mentally confusing, isn't it, that they use 'dataSubmitted' to get values when we haven't submitted to the server yet, and that their 'quick help' that explains how to get values from repeating section rows is found in those events about submitting. But it would all probably be more confusing to remember 2 different ways to get data depending on if function is called after submit or not... (which is how it is on grids and I found confusing... so .... whatever)
        Carol King
        Developer of Custom Homebuilders' Solutions (CHS)
        http://www.CHSBuilderSoftware.com

        Comment


        • #5
          Re: help with ajax callback

          Oh, my head hurts now.
          I think what I'm looking for is going to be in the else section.
          I spent most of yesterday getting my user-defined-function to work.
          Basically, crowflies(plon,plat,dlon,dlat) returns the distance between the 2 points.
          Now, i'm hoping with the push of a button to get that distance into the Miles control.

          I hate to do this, but is there any chance of you using the big hammer to hit me
          with what should be the obvious clue ?
          Gregg
          https://paiza.io is a great site to test and share sql code

          Comment


          • #6
            Re: help with ajax callback

            Gregg, if you post a copy or screenshot of your dialog and a code snippet of your function I can help you get it working.

            Comment


            • #7
              Re: help with ajax callback

              Starting to seem to me that Gregg is not needing to do an ajax callback.
              Carol King
              Developer of Custom Homebuilders' Solutions (CHS)
              http://www.CHSBuilderSoftware.com

              Comment


              • #8
                Re: help with ajax callback

                Hi Luke,

                I appreciate the offer but the hints that Carol gave me made sense once I chose server-side xbasic
                instead of action javascript.

                Probably the old dog in me, but I seem to be much better when doing
                this stuff via xbasic.

                I removed most of the notes from the function below.
                I think I was confused because of the part that says I need javascript to be returned by the function.

                Carol...please put that hammer down, but keep it available for future use :)

                Code:
                function serverside_9eedd3a599cd4f2f9c1e1bfdf59306fe as c (e as p)
                
                serverside_9eedd3a599cd4f2f9c1e1bfdf59306fe = "//Replace this with the javascript to be returned by the function."
                
                e._set.crow.value = crowmiles(val(e.datasubmitted.pickup_lon),val(e.datasubmitted.pickup_lat),val(e.datasubmitted.delivery_lon),val(e.datasubmitted.delivery_lat))
                
                end function
                Gregg
                https://paiza.io is a great site to test and share sql code

                Comment


                • #9
                  Re: help with ajax callback

                  Hammer is back in the toolbox. :)
                  Carol King
                  Developer of Custom Homebuilders' Solutions (CHS)
                  http://www.CHSBuilderSoftware.com

                  Comment


                  • #10
                    Re: help with ajax callback

                    Gregg,

                    I do basically the same thing. My dialog looks like the folowing. I have several ways to get the lat and long, this is the simplest.
                    screen1.jpg

                    The process button runs an ajax callback that sets the start and end points into session variables (I do that because my distance code and map are in the page, not the component)

                    So, to get the values I just use e.datasubmitted.Latitude
                    elseif vChoice = "LAL"
                    e.SESSION.LOC_CHOICE = "LAL"
                    e.SESSION.LOC_LSD = ""
                    e.SESSION.LOC_PROJECT = ""
                    e.SESSION.LATITUDE = e.dataSubmitted.Latitude
                    e.SESSION.LONGITUDE = e.dataSubmitted.Longitude
                    if val(e.SESSION.LONGITUDE) > 0
                    e.SESSION.LONGITUDE = "-"+e.SESSION.LONGITUDE
                    end if
                    SESSION.LOC_TITLE = alltrim(e.SESSION.LATITUDE)+", "+alltrim(e.SESSION.LONGITUDE)
                    end if

                    Then I calc the distance in a function like you do

                    FUNCTION Distance_between_points AS N (First_latitude AS N, First_longitude AS N, Second_latitude AS N, Second_longitude AS N, output_units AS C )
                    ' Version 2.0, by Pat May-16-12
                    ' This calculates the distance in miles or km between two points on earth based on their longitudes and latitudes
                    ' Inputs: First_latitude AS N, First_longitude AS N, Second_latitude AS N, Second_longitude AS N, output_units AS C (M = miles, K = kilometers, Y = yards

                    Then in the page (could also be in your callback)

                    pArray[..].distance = Distance_between_points(val(SESSION.LATITUDE),val(SESSION.LONGITUDE), crs.data(5), crs.data(6),"Kilometers")

                    Then on the page, I print a table sorted closest to farthest
                    screen2.jpg

                    and a map
                    screen3.jpg

                    Edit: OOPs, I type too slow....glad you got it to work
                    Pat Bremkamp
                    MindKicks Consulting

                    Comment


                    • #11
                      Re: help with ajax callback

                      Originally posted by kingcarol View Post
                      Starting to seem to me that Gregg is not needing to do an ajax callback.
                      It is quite possible that I am making this more difficult than it needs to be.
                      The attached images show in order:
                      1. The grid without the Crow Miles button. (did not have data in all required fields)
                      2. The grid with the Crow Miles button, but the crow miles control is blank.
                      3. The grid with the Crow Miles button and data in the crow miles control (I pressed the crow miles button).

                      If there is a better way and/or if I have my terminology mixed up, please let me know.



                      Gregg
                      https://paiza.io is a great site to test and share sql code

                      Comment


                      • #12
                        Re: help with ajax callback

                        Hi Pat,

                        Some of the projects you have done are the inspiration for a lot of what I am currently doing.
                        I still have a ways to go before my project will be live, but you have shown ways of using the
                        same project for different (but related) clients.
                        Gregg
                        https://paiza.io is a great site to test and share sql code

                        Comment


                        • #13
                          Re: help with ajax callback

                          Gregg,

                          Thanks for the kind words.

                          I suspect that the "crow" distance is for determining the delivery charge. If you decide to expand that to include delivery routing, then you'll face the same problem I did which was location a is 20 miles and location b is 21 miles, but the distance from a to b is 41 miles (opposite dirctions) . For that, the map is invaluable.

                          By the way, before anyone points out my error, I had accidentally left the page calculating yards instead of kilometers, and, yes, the longitudes are negative in Canada!
                          Pat Bremkamp
                          MindKicks Consulting

                          Comment


                          • #14
                            Re: help with ajax callback

                            The "crow" distance is actually from point A to point B.

                            I have to find a way to get point A and point B on the map,
                            as opposed to multiple point As.
                            Gregg
                            https://paiza.io is a great site to test and share sql code

                            Comment

                            Working...
                            X