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

InLine Ajax Callback plus calling javascript function

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

    InLine Ajax Callback plus calling javascript function

    So here is my problem

    I have a single record grid that once save needs to do several things.

    I have code in the Server-Side-Events: After Insert Record - works lovely no problems

    and in the Client-Side Events: afterGridSubmit - My code for this is below

    Code:
    if(e.hasErrors == false) {
        {grid.object}.closeParentContainer();
        alert('Your Task Has Been Added');
       
       var po = {Grid.Object}. getParentObject();
       if(po) po.refresh()
    
        var rowNum = {Grid.Object}._selectedRow;
        {grid.Object}.ajaxCallback('G', rowNum, 'notify','','_getData=true&'+assignvals());
    }
    Within this code I ALWAYS get the container to close, my alert and the refresh to work successfully

    The remaining code however is inconsistent. It works maybe 1 out of 30 times. So either it isn't in a good place of my syntax is off.

    So my questions are:

    1. Is my syntax off (and if so how to fix)
    2. Can I call an ajax callback from the AfterInsertRecord, if so how can I do that?

    I tried this in the AfterInsertRecord and it dididn't work
    Code:
    e.javascript = "var rowNum = {Grid.Object}.selectedRow;"
    e.javascript = e.javascript + "alert(rowNum);"        'Never got this alert
    e.javascript = e.javascript + "{grid.Object}.ajaxCallback('G', rowNum, 'notify','','_getData=true&'+assignvals());"
    Thanks so much for your help, I really appreciate any insight at all! :-)

    -Lily
    Last edited by RankFirstPro; 07-03-2013, 09:20 AM.

    #2
    Re: InLine Ajax Callback plus calling javascript function

    If it works sometimes... it sounds like it could be a timing issue. Maybe a timeout function to make it work?

    Comment


      #3
      Re: InLine Ajax Callback plus calling javascript function

      1) Are you missing a ";" after "alert(rowNum)" on line 2?
      2) Don't you need double-quotes on line 3 after the "+". But if you said it works sometimes, then I guess you have that part right in your code.
      3) I don't know about the "e.javascript", but if you are using Version 11, with a web-app, then the help text for that xbasic event (AfterInsertRecord) says to use :

      aa = e.rtc.A_AjaxResponses
      aa[].text = "alert('Message');"
      aa[..].id = 100 'the order in which AjaxResponses are sent to the browser
      I send javascript back in my app from the 'AfterUpdateRecord' server event. My code looks like this:

      aa = e.rtc.A_AjaxResponses
      aa[].text = RefreshCommentFlags(e)
      aa[..].id = 100 'the order in which AjaxResponses are sent to the browser
      My "RefreshCommentFlags" xbasic function returns a string of javascript to call a javascript function that I've declared in the component. I kind of remember finding out it was best to send back javascript that called called other javascript functions that were declared in the components properties rather than trying to do very much inline.

      My "RefreshCommentFlags" xbasic function returns the string of javascript using something like this:
      RefreshCommentFlags = "UpdateParentCmntFlags(" + LocDR_SysID + "," + \
      quote(drFlags[1].drPerson1_Comment_Flag,"'") + "," + \
      quote(drFlags[1].drPerson2_Comment_Flag,"'") + "," + \
      quote(drFlags[1].drPerson3_Comment_Flag,"'") + "," + \
      quote(drFlags[1].drPerson4_Comment_Flag,"'") + " ); "

      It has been quite a while since I tested that bit of code and as I have been applying pre-releases I cannot say for certain if it still works, though.

      Comment


        #4
        Re: InLine Ajax Callback plus calling javascript function

        Thanks guys for the responses :-)

        Lee: Where would I put a timeout function?
        Rich: I hand typed the code and missed a few things in translation but as far as #1 yes, that was in there, #2 I don't think so, because it's a function

        As for the rest of your notes, I am using v11 web I've never used your example code before so I probably am doing something wrong

        Code:
         
        aa = e.rtc.A_AjaxResponses
        aa[].text = "{grid.Object}.ajaxCallback('G', rowNum, 'notify','','_getData=true&'+assignvals());"       'Did an alert test and that worked without a problem
        aa[..].id = 100
        I also tried just calling the javascript function and putting

        Code:
         aa = e.rtc.A_AjaxResponses
        aa[].text = "{grid.Object}.loadJavascript('function assignvals(){}');"
        aa[..].id = 100 'the order in which AjaxResponses are sent to the browser
        That didn't work either

        Tried
        e.javascript = "{grid.Object}.loadJavascript('function assignvals(){}');"

        and it can't find the function, the function is all lower case so I don't think I should have a case issue, but I don't know why that wouldn't work.

        I keep trying, but I am not missing anything.

        Somehow I need to get that javascript function called in xbasic, it can be through an ajax callback (which I'd prefer) or any other method. I'm just missing something. Any other suggestions?
        Last edited by RankFirstPro; 07-03-2013, 12:27 PM.

        Comment


          #5
          Re: InLine Ajax Callback plus calling javascript function

          I could be wrong but I think you need to wrap the code you are trying to execute into a javascript function and put it into the component's "Code / Javascript functions" property. I just don't think you can use the placeholder "{grid.Object}" in the javascript set by "AfterInsertRecord" because the placholder,"{grid.Object", will not get replaced with the object name that is supposed to be there. If you wrap that code into a function declared in the component's "code / javscript functions" property then it will.

          Also, I don't think you can use 'rowNum' like that. You probably need to get a pointer to the parent grid and then use the 'rowNumber' property. If you are just trying to refresh the parent row then you can just call the parent grid method 'refreshRow'. I suppose you would put something like this in the child grid's Javascript Functions property:

          function refreshMyParent() {
          var pg = {grid.Object}.getParentObject();
          if(pg) {
          var r = pg.rowNumber;
          pg.refreshRow(r);
          }
          }
          In the "AfterInsertRecord" server xbasic fucntion put

          aa[].text = "refreshMyParent();"
          To ensure a delay then wrap the call in the 'setTimeout' javascript function:

          aa[].text = "setTimeout( refreshMyParent, 100);"

          Comment


            #6
            Re: InLine Ajax Callback plus calling javascript function

            Have you tried firing the ajax callback and returning the javascript function?

            at the end of your xbasic return

            notify = "assignvals()"
            Creating Healthcare Work-Flow Solutions Since 2005

            Comment


              #7
              Re: InLine Ajax Callback plus calling javascript function

              You can use {grid.object} and you SHOULD use {grid.object}. Especially if you can have two or more instances of this grid active in the same window.

              I put this in a grid to test AfterInsertRecord:
              Code:
              	aa = e.rtc.A_AjaxResponses
              	aa[].text =<<%js%
              	alert("multi-line demo");
              	var rowNum = {grid.object}._selectedRow;
              	alert("Row num is " + rowNum);
              	{grid.object}.ajaxCallback('G', rowNum, 'notify','','_getData=true&'+assignvals());
              	%js%
              	aa[..].id = 100
              I put this in my xbasic function definitions:
              Code:
              function notify as c (e as p)
              	dim testval as C = e.test
              	notify = "alert('notified! testval = " + js_escape(testval) + "');"
              end function
              And I defined assignvals() in my javascript code section:
              Code:
              var assignvals = function ()
              {
              	return "test=true";
              }
              Hope this helps.
              ---
              Sarah
              Alpha Anywhere latest pre-release

              Comment


                #8
                Re: InLine Ajax Callback plus calling javascript function

                Hi,

                This might not be relevant to this post but, is it possible to use loadJavascript or loadJavascriptFile in a UX component?

                Thank you.

                Pevisha

                Comment


                  #9
                  Re: InLine Ajax Callback plus calling javascript function

                  Originally posted by PevishaJ View Post
                  Hi,

                  This might not be relevant to this post but, is it possible to use loadJavascript or loadJavascriptFile in a UX component?

                  Thank you.

                  Pevisha
                  I can't speak for a version 12 "UX" component, but the functions exist for a dialog component in version 11.
                  Alpha Anywhere latest pre-release

                  Comment


                    #10
                    Re: InLine Ajax Callback plus calling javascript function

                    Thanks Sarah,

                    I still have some confusion around it. Do we use {grid.Object}.loadJavaScript ? Or is there {dialog.Object}.loadJavaScript?

                    Pevisha

                    Comment


                      #11
                      Re: InLine Ajax Callback plus calling javascript function

                      Originally posted by PevishaJ View Post
                      Thanks Sarah,

                      I still have some confusion around it. Do we use {grid.Object}.loadJavaScript ? Or is there {dialog.Object}.loadJavaScript?

                      Pevisha
                      If you're working with a grid, you use {grid.object}. If you're working with a dialog2, it's {dialog.object}.
                      Alpha Anywhere latest pre-release

                      Comment


                        #12
                        Re: InLine Ajax Callback plus calling javascript function

                        I tried that but I might be getting something mixed up as it is still not working as I want it to.

                        So, just to test I created a .js file called add.js which has a function called sum.

                        I also created an UX Component with 2 textboxes and a button. All I want to do is call the sum function in add.js when the button is clicked.


                        Thanks,

                        Pevisha

                        Comment


                          #13
                          Re: InLine Ajax Callback plus calling javascript function

                          include the js file using the "Javascript Linked Files" property for the component and call function normally.
                          Alpha Anywhere latest pre-release

                          Comment


                            #14
                            Re: InLine Ajax Callback plus calling javascript function

                            For the record, if you've used {dialog.object} in your .js file, it's not going to work how you expect. Alpha 5 replaces {dialog.object} with the actual object when the component is processed for publishing. If you want to reference {dialog.object} inside your .js file, then you'll need to pass it in as a parameter to your function(s).

                            As for including a javascript file in your component, you can use the Javascript Linked Files property. Or you can load it using the <script> HTML tag in the page header:

                            Code:
                            <script type="text/javascript" src="relative/path/to/javascript.js"></script>
                            Or you can use the loadJavaScript function. If you're not dynamically generating/loading the file, I would use the javascript linked files option.
                            Alpha Anywhere latest pre-release

                            Comment


                              #15
                              Re: InLine Ajax Callback plus calling javascript function

                              Thank you so much Sarah,


                              It worked!

                              Pevisha

                              Comment

                              Working...
                              X