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

Select Grid Row, Set session variable

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

    Select Grid Row, Set session variable

    Despite the AJAX stuff, I still can't figure this out:

    How can I create a control on a multi-line grid that, when clicked, sets a session variable?

    In my case, I have 15 or 20 records showing on a grid at any one time. Each has an Order_ID. I want the user to be able to click on some control on each line that allows me to set session.order_ID.

    There are a couple threads about this, including a longer one discussing whether a custom control can be used. I think not, but it still seems like a good candidate. As Steve Wood points out in that thread, all you get is the last order_id in a multi-line grid.

    Ideas?
    -Steve
    sigpic

    #2
    Re: Select Grid Row, Set session variable

    Steve,

    Screen1 shows the setup to create the session variable. Set one field to be a link and define it as shown. It ususally works best to use a calculated field for the link rather than the field itself. So you have the field Order_id and set the link on calcOrder_id defined as =Order_Id.

    Then, use the session as a filter. If the target is a grid, then define an argument based on the session variable and set a filter based on some variable equal to that session variable. See screen2 and screen3.

    Pat
    Pat Bremkamp
    MindKicks Consulting

    Comment


      #3
      Re: Select Grid Row, Set session variable

      Thanks Pat. I know the stuff you show here. But I don't want a link that redirects the page - I don't want a "target."

      All I want to do is have the user click something to select a row, and have that click set the session variable.
      -Steve
      sigpic

      Comment


        #4
        Re: Select Grid Row, Set session variable

        Steve,

        Unless I am missing your point, it seems to me that what you want to do is pretty close to waht Pat said.

        Simply define a calculated field called say "var" - link this to a dummy page that does nothing, but you can then define session variable(s) either in the page or in the link from the grid to the page.

        Gary
        Gary S. Traub, Ph.D.

        Comment


          #5
          Re: Select Grid Row, Set session variable

          Any link you do that way makes an href, which takes you to another page.

          I don't want to move off the current page - just and only set a session variable.

          Each row of data in the grid has an order_id.

          I have a set of buttons outside the grid to do things but I need first to select the session variable of the row the user wishes to act upon.
          -Steve
          sigpic

          Comment


            #6
            Re: Select Grid Row, Set session variable

            Steve,

            You may come up with a more direct method, but the following does work:

            Do as I described above, i.e., link to a dummy page, define the session variable within the Link Address Builder.

            Then, create a dummy page that has nothing in it except the following:

            <html>
            <head>
            <meta name="generator" content="Alpha Five HTML Editor Version 9 Build 1479-3182">
            <title></title>

            <script language="JavaScript" type="text/javascript">
            javascript:window.history.go(-1);
            </script>

            </head>

            <body>

            </body>

            </html>

            This will create the session variable with the idnumber of the row you are on, and the dummy page's java script will return you right back to the grid.

            Gary
            Gary S. Traub, Ph.D.

            Comment


              #7
              Re: Select Grid Row, Set session variable

              Actually, you don't need another page. Just call the same page in the link, it will be perfectly happy to call itself.

              Pat
              Pat Bremkamp
              MindKicks Consulting

              Comment


                #8
                Re: Select Grid Row, Set session variable

                Yes, that works too :D
                Gary S. Traub, Ph.D.

                Comment


                  #9
                  Re: Select Grid Row, Set session variable

                  On second thought, I think it is a bit quicker to use the separate page with the java script because the page with the grid does not have to reload.
                  Gary S. Traub, Ph.D.

                  Comment


                    #10
                    Re: Select Grid Row, Set session variable

                    Since a session variable exists on the server, how could you create a session variable with out making a round trip to the server (AJAX or otherwise)? Secondarily, how would the session variable be of any use to you if it was suddenly magically set on an untouched/unrefreshed page? The only time it is going to be of any use is when you move to another page where it can be 'deployed' in some manner. (I'm sure you have an answer, I just can't figure it out.) AJAX is the way to go and would create the least amount of visual screen refresh, but I don't know how you would do it. (Apparenly not paying attention during your class on the subject.)

                    Gary's solution is the same as creating a code-only page with:

                    session.myvar=id
                    response.redirect(request.referer)
                    where id comes in the URL or POST.
                    Steve Wood
                    See my profile on IADN

                    Comment


                      #11
                      Re: Select Grid Row, Set session variable

                      Steve,

                      That explanation was useful for me to hear. It reminds of the difference between server and client side issues.

                      Thus, if I read you right, the only way Steve (Workings) can do what he wants is to make some call to the server - he cannot do what he wants "without leaving the page." Which also means that my second method, using java script, would not work, because all that does is goes back one page in the cache.

                      So, Pat's suggestion of redirecting to the same page is probably the fastest (other than AJAX).But if the page is relatively small, AJAX probably would not be needed. Otherwise, if there are a lot of fields on the page for example, then AJAX would likely make a big difference.
                      Gary S. Traub, Ph.D.

                      Comment


                        #12
                        Re: Select Grid Row, Set session variable

                        Setting a session variable on the server using AJAX is a very trivial operation using a custom control and a AJAX callback. You need a very simple callback page and a simple onclick event on a button in the control.

                        First create the callback page. In this example, the session var name can be set dynamically by sending the name to use and the value to populate as variables in the call back. The call back sends 2 values, 'var', which is the name of the session variable, and 'varvalue', which is the character value to place in the session variable. If the session variable isn't character, you would need to send a data type variable value as well. Something like 'vartype=T' would work to tell the callback to convert the type to the 'T' type, which is time. This is all you need on the page.
                        Code:
                        <%a5 
                        dim var as c
                        dim varvalue as c
                        if var <> ""
                        	eval("session."+var) = varvalue
                        end if
                        %>
                        In this example (which doesn't include any code for setting type), that was saved on a page named 'setvar.ajax.a5w'. On the grid, create a custom control that uses an AJAX callback on the 'onclick' for the field that is the source. In this example, the source is the 'customer_id' field. The control can be any control that has an 'onclick' event.
                        Code:
                        Customer_id_render = "<input name=\"setvar\" type=\"button\" value=\"Set Session\" onclick=\"a5_AJAX_Callback('setvar.ajax.a5w','var=custid&varvalue="+Data.Customer_id+"')\"/>"
                        Of course, the JavaScript files needed for the AJAX must be added to any page that has this grid. They can be added in the page header just after the <title></title>
                        HTML Code:
                        <script type="text/javascript" src="javascript/core.js"></script>
                        <script type="text/javascript" src="javascript/aui.js"></script>
                        <script type="text/javascript" src="javascript/AjaxFormLibrary.js"></script>
                        Publish both pages. When the page with the grid is run, clicking the button will set the session var 'session.custid' on the server with a value that matches the 'customer_id' in the row that had the button. The value at this point only exists on the server. You could send the value back to the original grid and populate a control, but if the session var is used for any purpose in this grid such as filtering, the whole page must be refreshed by making a request back to the server. If that is the case, using AJAX is unnecessary.

                        Comment


                          #13
                          Re: Select Grid Row, Set session variable

                          Thanks Jerry, that's exactly what I needed.
                          -Steve
                          sigpic

                          Comment

                          Working...
                          X