Alpha Video Training
Results 1 to 11 of 11

Thread: Set Session Variable Based on Selected Grid Row

  1. #1
    Member
    Real Name
    Rick Smereka
    Join Date
    Aug 2006
    Location
    Southwestern Ontario, Canada
    Posts
    29

    Default Set Session Variable Based on Selected Grid Row

    I have a grid linker containing five grids:

    Department
    Zone
    Dealer
    Customer
    Order

    I am trying to set some session variables based on one of the selected row values in the grid.

    I have tried using the code:
    Code:
    <%A5 session.grid_department = {ParentGrid:Department} %>
    in the zone grid 'above grid' 'freeform edit region' which does resolve the selected department correctly except with the error:
    Code:
    Error:Script:EVALUATE_A5W line:4 session.grid_department = 10 Invalid date constant
    I know it does not make much sense assigning a session variable from the 'freeform edit region' but grids do not have an appropriate static HTML area required by 'ParentGrid'.

    Anyone have any idea what this error means. I am at at loss since there are no dates involved. Or better yet, is there are better way to set session variables based on a selected grid row within a grid linker?

    Any/all help is greatly appreciated.
    Happy holidays everyone :)
    Rick

  2. #2
    Volunteer Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,644

    Default Re: Set Session Variable Based on Selected Grid Row

    This thread might help you:
    http://msgboard.alphasoftware.com/al...ad.php?t=64593

    Look at Pat's post at the bottom for method to capture multiple fields.

  3. #3
    Member
    Real Name
    Rick Smereka
    Join Date
    Aug 2006
    Location
    Southwestern Ontario, Canada
    Posts
    29

    Default Re: Set Session Variable Based on Selected Grid Row

    Thanks for the suggestion Peter,

    I read the thread and I don't think I can use the method suggested since I have multiple grids and am not able to use links in place of labels.

    Basically, I am planning to put a button below all the grids with the title 'place an order' or something like that. This button would redirect the user to the order page, at which point, I will need to have stored somewhere the current:

    department
    zone
    dealer
    customer

    Agreed that I could pass these in the URL of the page re-direct, however, I will still need to keep track of these values as the user selects records in the various grids.

    Any other suggestions? Anyone.
    Rick

  4. #4
    VAR Pat Bremkamp's Avatar
    Real Name
    Pat Bremkamp
    Join Date
    Apr 2000
    Location
    Oregon, USA
    Posts
    2,629

    Default Re: Set Session Variable Based on Selected Grid Row

    Rick,

    OK, I think I get what you are trying to do. You want the user to select rows on each of the grids, then assign the resulting values to session variables with one button press. So, perhaps you should consider a different way to do the same thing.

    If it was me, I'd use a dialog component and put each of the four choices either in a dropdown or a lookup grid. That way, if any of the "lower" choices are dependent on the prior choice (say different dealers in different zones) you can make the list of choices change when the prior selection is made.

    Then you can easily assign the session variables with Xbasic in the AfterValidate event.

    Another advantage...gridlinkers are slow and dialogs are fast(er).

    Pat

  5. #5
    Member
    Real Name
    Rick Smereka
    Join Date
    Aug 2006
    Location
    Southwestern Ontario, Canada
    Posts
    29

    Default Re: Set Session Variable Based on Selected Grid Row

    Pat,

    Thanks for the suggestion.

    I think I understand what your idea is although I have a couple of questions if you don't mind.

    Firstly, what is a 'lookup grid'? Second, the users have said that they need to see more than one piece of information in order to make a selection. For example, in the case of selecting a dealer, I must display the dealer number, full name and company name. If I use a drop-down, can I concatenate all of this into one entry? Or maybe there is another way of presenting more than one piece of information.

    Rick

  6. #6
    VAR Pat Bremkamp's Avatar
    Real Name
    Pat Bremkamp
    Join Date
    Apr 2000
    Location
    Oregon, USA
    Posts
    2,629

    Default Re: Set Session Variable Based on Selected Grid Row

    Rick,

    Sure. Here are some examples from an application I'm working on.

    A lookup grid is just a grid component. You make this first with whatever info you want to display. In screen1, this is the grid in the lower right. This component displays fields that you want to copy into your main component. You do not create a page for this component. I usually make it read only for speed and compactness and add a quick search for long lists. Then, in the field definitions for the field in your dialog is a property called "Lookup". Check that box and it will guide you through specifying the lookup grid name and mapping the fields from the lookup grid to corresponding fields in your dialog. The little spyglass is the icon that triggers the lookup.

    Screen2 shows a dropdown with more than one field displayed. In this case, I made the display and expression equal to ID_Code+" "+Name. You can then save those or entirely different fields from the record.

    Pat

  7. #7
    Member
    Real Name
    Rick Smereka
    Join Date
    Aug 2006
    Location
    Southwestern Ontario, Canada
    Posts
    29

    Default Re: Set Session Variable Based on Selected Grid Row

    Pat,

    Great explaination, thanks Pat.

    I think I'll proceed with the lookup method which bring me to another question. Can I do multiple look-up prompts? For example, each one of these would be a lookup that qualifies the previous ones:

    Department: --- Select one ---
    Zone : --- Select one ---
    Dealer : --- Select one ---
    Customer : --- Select one ---

    Obviously, the lookup lists would have to be dynamically loaded based on the previous selection. Any thoughts?

    Rick

  8. #8
    Member
    Real Name
    Steve Hanson
    Join Date
    Jul 2006
    Posts
    51

    Default Re: Set Session Variable Based on Selected Grid Row

    I assume you've moved forward on this but if you haven't, just some thoughts on what you could do.

    I'm doing something very similar to what you're doing. I created a dialog with 7 drop down lists each of which references a different table.

    Yours is different because you've got a dependency relationship between the choices. Basically choice #1 filters choice #2, etc. assuming I understand it correctly. What you do will be dependent, possibly, on the amount of data being filtered. If it's going to be a lot, you probably don't want to send it all out there and let a javascript modify the dropdown lists (assuming that is even possible).

    What would really be cool is if you could make choice # 2 visible only after choice #1 was made, and at the same time trigger a request to the server for just the data that you'll show in choice #2, etc. That would keep the traffic down and you wouldn't be regenerating the entire page.

    Of course, you could just go to a new page which picked up the filtered data for choice#2 but I seem to remember you saying that the user wanted to see or have the ability to see, the previous stuff too.

    what did you end up doing?

  9. #9
    Member
    Real Name
    Rick Smereka
    Join Date
    Aug 2006
    Location
    Southwestern Ontario, Canada
    Posts
    29

    Default Re: Set Session Variable Based on Selected Grid Row

    Steve,

    Yes I did move forward based on Pat's original suggestion of using drop-down's. And as Pat said, they are so much faster than grid's. I have this whole page just about done. There are four drop-downs that depend on the previous one and the final component which shows the detail is a read-only grid. I am using parameters in each drop-down based on session variables. I choose session variables because I will also be placing another button on the main dialog that allows the user to place an order (which will be redirected to another page) based on all the current relationships.

    Funny, I was just thinking that it would be great to make one or more drop-downs invisible based on a previous selection. For example, I have departments where there are no zones and/or no dealers. I still have to figure out how I am going to accomplish that. My current idea is to use some kind of 'all' flag for the session variable and cause the DB filtering not to ocurr. But it would be much cleaner if I could just remove one or more of the drop-downs from the dialog.

    Rick

  10. #10
    Member
    Real Name
    Steve Hanson
    Join Date
    Jul 2006
    Posts
    51

    Default Re: Set Session Variable Based on Selected Grid Row

    You could make the subsequent selections invisible until a prerequisite selection is made. Javascript might be able to accomplish that through the onclick event.
    Here's a place to check that out: http://www.w3schools.com

  11. #11
    Member
    Real Name
    Rick Smereka
    Join Date
    Aug 2006
    Location
    Southwestern Ontario, Canada
    Posts
    29

    Default Re: Set Session Variable Based on Selected Grid Row

    Steve,

    Thanks for the tip. I'll check it out. I have used W3schools before to brush up on HTML and CSS.

    Rick

Similar Threads

  1. Create session variable from value in grid
    By den1s in forum Web Application Server v7
    Replies: 4
    Last Post: 11-03-2011, 12:31 PM
  2. Getting the variabels of the selected grid row
    By B.B.Bongers in forum Web Application Server v7
    Replies: 4
    Last Post: 10-25-2006, 02:58 PM
  3. showing only a selected record in set based form
    By MikeC in forum Alpha Five Version 5
    Replies: 4
    Last Post: 03-27-2006, 01:06 AM
  4. Replies: 2
    Last Post: 12-21-2005, 07:09 PM
  5. Set session variable from grid selection
    By Pat Bremkamp in forum Web Application Server v6
    Replies: 2
    Last Post: 09-27-2004, 08:57 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •