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

session variable trap

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

    #16
    Re: session variable trap

    Yes I did. No luck either.

    Is it this difficult to pass variables from grid to grid?
    Gary S. Traub, Ph.D.

    Comment


      #17
      Re: session variable trap

      Basically we have only a few types of variables to work with. Sessions variables more or less live on the server but can be referenced in certain places in your grids. Javascript vars (local and global) live in the user's browser. The challenge is that often the data you want is on the server and you need it somewhere in Javascript and vice-versa. There is also page variables that are useful if you are interacting with a5w pages (but not useful with what you are doing).

      Since you needed to initialize the grid (as opposed to the detail view which my earlier solution provided for), it appears you'll need to resort to using a session variable in the OnIntitalValueCalculate client event... or better yet you can enter a session var in the initial value property. For this to work, I think you will need to register the session variable in the "Published Session variables property", which can be found at the end of the Grid properties. Remember it needs to be all upper case in there.

      But how do you set the session variable in the first place on the grandparent grid? Well, you can do an Ajax call-back to set the session variable. You would make the call-back from the Javascript in the button on your grandparent grid. Normally there is a timing issue in that by the time the server creates/updates the session variable, the linked-to grid is rendered and the session variable doesn't exist on the child grid yet. There is a method to solve this if you need to (I can explain that in another post if required). However, since you have a grandchild grid, two grids away, the session variable is almost certainly created by the time your user gets there.

      If you need help with doing the call-back, let me know, it is really fairly easy to do.

      --> I should have mentioned, if the value you want to pass is to exist in the child and grandchild grids (e.g. a common key), then you can simply include it as one of the link fields in the call-grid definition.

      Comment


        #18
        Re: session variable trap

        I should have mentioned, if the value you want to pass is to exist in the child and grandchild grids (e.g. a common key), then you can simply include it as one of the link fields in the call-grid definition.

        Vaughn,

        Thanks so much for all this information - it is immensely helpful. I will make use of it in a lot of ways. But for this issue, I did originally set things up as link fields. That usually works, but not always. Perhaps it is a bug. If I have 3 grids, and grid2 has at least 1 record, then the linking does successfully carry the linked values to grids 2 and 3. However, if grid2 has no records, grid3 does not get the linked values. It is as if, since there are no records in grid2, there are no fields there to store the values and thus no values to transfer to grid3.
        Gary S. Traub, Ph.D.

        Comment


          #19
          Re: session variable trap

          Originally posted by drgarytraub View Post
          I should have mentioned, if the value you want to pass is to exist in the child and grandchild grids (e.g. a common key), then you can simply include it as one of the link fields in the call-grid definition.

          Vaughn,

          Thanks so much for all this information - it is immensely helpful. I will make use of it in a lot of ways. But for this issue, I did originally set things up as link fields. That usually works, but not always. Perhaps it is a bug. If I have 3 grids, and grid2 has at least 1 record, then the linking does successfully carry the linked values to grids 2 and 3. However, if grid2 has no records, grid3 does not get the linked values. It is as if, since there are no records in grid2, there are no fields there to store the values and thus no values to transfer to grid3.
          try to create a dummy [hidding] record based on the valus of grid2 in grid3 create a field unbound name it 'mydummy' exclude that from the transaction in grid 3.
          Create it in the Grid (init) as a new row with the object fields ROW1 make the row dirty and set the defaults for row2. That will trigger the row expander at runtime

          To my understanding this question and the reaction behavior of the row expander has been modified in V11 but you have to check that yourself read the release notes for V11 beta
          Last edited by bea2701; 11-07-2011, 09:18 PM.

          Comment


            #20
            Re: session variable trap

            Originally posted by drgarytraub View Post
            Thanks so much for all this information - it is immensely helpful. I will make use of it in a lot of ways. But for this issue, I did originally set things up as link fields. That usually works, but not always. Perhaps it is a bug. If I have 3 grids, and grid2 has at least 1 record, then the linking does successfully carry the linked values to grids 2 and 3. However, if grid2 has no records, grid3 does not get the linked values. It is as if, since there are no records in grid2, there are no fields there to store the values and thus no values to transfer to grid3.
            I see. Just curious, how do you link from grid2 to grid3 without grid2 having any records?

            Comment


              #21
              Re: session variable trap

              Grid 3 is accessed via an action button from grid2
              Gary S. Traub, Ph.D.

              Comment


                #22
                Re: session variable trap

                In the Javascript for the button could you not check to see if the key on the current row of grid2 is null (not there) and pop up an alert to the affect that a row needs to be selected? This would have the same effect as putting the button on the row (if there is no row then you can't click the button because it doesn't appear). I'm assuming it doesn't make sense to go to grid3 without the user having selected a row in grid2.

                Comment


                  #23
                  Re: session variable trap

                  Thanks, but that wont work. The button goes to a grid that will enter a new record. When user clicks submit, the popup closes, returns to grid2, and needs to show the record that was just added. But it wont show because idnumber was not passed to grid3. I hope that clarifies.
                  Gary S. Traub, Ph.D.

                  Comment


                    #24
                    Re: session variable trap

                    So, a record in grid2 doesn't need to exist before a record in grid3 is created? If so, why isn't grid3 connected directly to grid1 in which case the link with id's would work as you desire?

                    Comment


                      #25
                      Re: session variable trap

                      Good point, but here is the scenario. Grid 1 is a list of appointments. User clicks on an appointment and opens a detail view. On the detail view, there is a lookup icon that when user clicks, of course opens a lookup. The lookup has an action button that when user clicks opens a grid to enter a new record. If the lookup (grid2) has records in it, then no problem. If it doesn't have records, then we have the problem. I suppose I could put the NewRecord button on grid 1's detail view, and that would work, but that is not what I really want to do
                      Gary S. Traub, Ph.D.

                      Comment


                        #26
                        Re: session variable trap

                        Okay, as we've learned you can't use the Javascript variables because the new record is on a grid (and we haven't found a client event in which to initialize the value). You therefore will need to use a session variable. Here is what you can do:

                        1. In grid1, in the onRowSelect client event, add this Javascript snippet. This does an Ajax callback. The ReturnGrid1ID is a javascript function that will get you the value of your id (I have called it GRID1ID here):

                        var rowNum = {Grid.Object}._selectedRow;
                        {grid.Object}.ajaxCallback('G',rowNum,'SetSessVars','','Data=true&' + ReturnGrid1ID());

                        2. In grid1, in the Javascript section, add this. This function returns "_var1=xxxx:", where xxxx is your id. This is passed to Xbasic as e._var1 where the session variable will get set.

                        function ReturnGrid1ID() {
                        var rowNum = {Grid.Object}._selectedRow;
                        var Grid1ID = {Grid.Object}.getValue('G','GRID1ID',rowNum);
                        return "_var1=" + Grid1ID ;
                        }

                        3. In the Xbasic section of grid1, add this:

                        function SetSessVars as c (e as p)
                        e.session.__protected__Grid1ID = e._var1
                        'The following is a debug line (uncomment to see the value of the session var stored in file c:\mylog.txt):
                        'save_to_file("Grid1ID:" + e.session.__protected__Grid1ID + crlf(),"c:\mylog.txt", .t.)
                        end function

                        ---> The only issue with this is that the call back will occur every time the user selects a row, which is what you want. Since you need it in a grandchild grid you should be okay (i.e. there is a potential timing issue if it would be needed on the child grid).
                        Last edited by cFlat7; 11-08-2011, 04:14 PM.

                        Comment


                          #27
                          Re: session variable trap

                          Hi Vaughn,

                          Really, really appreciate this help. Please help with some questions though:

                          1. the ajaxcallback function has more than 3 parameters in your code - is that correct?

                          2. regarding your step 2, where "in the Javascript section" does that code go? - in "javascript function declarations"?

                          3. does step 3 code go in the "Xbasic function declarations"??
                          Gary S. Traub, Ph.D.

                          Comment


                            #28
                            Re: session variable trap

                            Vaughn,

                            I got it working!!!!

                            I cannot thank you enough
                            Gary S. Traub, Ph.D.

                            Comment


                              #29
                              Re: session variable trap

                              Sorry, I didn't get to answer your questions as I was in a meeting all morning.

                              Glad to hear you got it working.

                              Comment


                                #30
                                Re: session variable trap

                                And again, I really appreciate you taking the time to teach. I not only got what I needed to fix a major road block for me, but I also learned a lot. Thanks again.
                                Gary S. Traub, Ph.D.

                                Comment

                                Working...
                                X