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

filter a list via a session variable

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

    filter a list via a session variable

    I have a grid list based on a MySQL table.
    I need to filter the list based on a crlf delimited session variable.
    The session variable has a list of com_id's like this:

    A2674
    A2686
    D2625
    H212

    How do I set up the filter in the grid? As you see there is an argument which is the session.comlist variable. This doesn't work, so I don't know how to do it.
    Any thoughts?

    Thanks,
    mike
    filter.jpg
    Mike Reed
    Phoenix, AZ

    #2
    Re: filter a list via a session variable

    Hi Mike,

    It would work if your argument value was in a comma-delimited, single-quoted format like:
    'xxx','yyy','zzz'

    Andy.

    Comment


      #3
      Re: filter a list via a session variable

      ^
      Yup, it should. I use the SQL "IN" with a comma delimited list as a grid filter in more than one case and it works great.

      Comment


        #4
        Re: filter a list via a session variable

        This doesn't work.

        I have tried several ways to assign the session variable to get it to work in the grid and nothing works.

        'xxx','yyy'
        xxx, yyy
        xxx,yyy
        'xxx' + crlf() + 'yyy'
        xxx + crlf() + yyy
        'xxx, yyy'

        etc...

        even tried to make the session variable an array...can't do that.

        The only that works is if the session variable is a single value such as xxx no quotes

        I'm at a loss on how to get this grid to display with multiple value. Does anyone have an idea?

        Thanks,
        mike
        Mike Reed
        Phoenix, AZ

        Comment


          #5
          Re: filter a list via a session variable

          Sometimes there's trouble with arguments and whether they have single quotes around them and what have you. I looked through some of my Xbasic and found how I was setting a variable for an SQL "IN". It's not a session variable but it's a string so it should be the same.

          Code:
          flag = rs.NextRow()
          if flag then
          dim userfilter as c
          userfilter = "unique_id IN ("
          dim cnt as n
          while flag
          userfilter = userfilter+rs.Data(1)+", "
          cnt = cnt + 1
          flag = rs.NextRow()
          end while
          userfilter = rtrim(userfilter,",")+")"
          'vjscmd = "alert('You Have "+cnt+" Open Requests');"
          vjscmd = "$('openrdiv').innerHTML='<h2>"+name+", You have "+cnt+" Open Requests</h2>';var userfilter = '"+userfilter+"';alert(userfilter);{grid.Object}.gridFilterSet(userfilter);"
          else 
          vjscmd = "$('openrdiv').innerHTML='<h2>"+name+", You Currently Have No Open Requests</h2>';"
          end if
          Ignore the extraneous shiznit in my code above and just look at how I set up the userfilter variable. I only included the other stuff to provide context. I know this works.

          In any case, istead of having "IN :comlist" as your filter, with the above method of setting the variable, you would just put in :comlist since "IN" is included in the variable used to set the argument.

          Comment


            #6
            Re: filter a list via a session variable

            I would agree that is should work, but it doesn't...unless of course I have done something wrong somewhere. So here is my setup....

            As part of the user login there is a process that runs to set this variable: session.comlist
            For testing purposes the variable is set manually with this command:

            session.comlist = " 'L773,'A2674' "

            The attachment shows the Define Arguments section and a picture of the grid Section that I have setup.
            If the session.comlist is set as "L773" in the login routine, the grid will display, otherwise using all the other combinations I tried will not.

            If I am to use your code, then I'll have to figure a way to use it in the "Code" section of the grid, so I'll give that a try. Thanks for sending that.

            Other note: Even in the section where you Define Arguments if I set the value to anything other than L773, the grid will not display in working preview, again using various formats.
            Attached Files
            Last edited by Mike Reed; 03-12-2014, 11:19 AM.
            Mike Reed
            Phoenix, AZ

            Comment


              #7
              Re: filter a list via a session variable

              The first thing I'd try is to set your session variable like this:

              session.comlist = "COM_ID IN ('L773','A2674')"

              and set your filter to only: :comlist

              Basically, putting the whole filter into your argument instead of separating it.

              And see if it works in your current setup.

              If so, we can work on building your variable. If not, we can try something else.

              Comment


                #8
                Re: filter a list via a session variable

                I liked that idea.....
                but this came up.

                GRID2.jpg
                Mike Reed
                Phoenix, AZ

                Comment


                  #9
                  Re: filter a list via a session variable

                  Will it work if you switch to native SQL? Also, can you go to advanced/other properties in your grid and set it to show the SQL?

                  Comment


                    #10
                    Re: filter a list via a session variable

                    Actually, you may be able to just check "Show query statements on Ajax callbacks" under "Advanced" in the grid properties. That should show your statement and what is in the argument when you perform a search on the grid. Also, I just noticed you are using "table or view" in your query definition. Try switching it to "SQL select statement" and then use the query builder. It may allow you to save it then, even with a "supposed" error. That way you can at least debug it while running your component.

                    Comment


                      #11
                      Re: filter a list via a session variable

                      Thank you for your help! I appreciate it.

                      I will work on these ideas today and see where I go with them. Gotta finish some other things, then I'll go back to this.

                      Again,
                      thanks,

                      Mike
                      Mike Reed
                      Phoenix, AZ

                      Comment


                        #12
                        Re: filter a list via a session variable

                        I think the issue there is that if your argument is defined as CHARACTER, the A5 may automatically add single quotes around it.
                        This will mess up the string being passed to the database server. Haven't looked into it, but one option would be to drop the first and last quotes (bit of a cludge).

                        Comment


                          #13
                          Re: filter a list via a session variable

                          I created a test case and have been messing with it. It definitely has something to do with how alpha is passing the argument into the sql query and quotes or something. I can't seem to get it to work even fudging it like Andy said. Even if you look at the SQL alpha is passing in when you use QBF syntax in a search field; for example: L773,A2674, All alpha does is turn it into a LIKE, AND LIKE statment instead of using "IN". There may be a setting somewhere that I'm unaware of to change how it works.

                          The other way to get around this is to set a filter after the grid is initialized using Xbasic. This is what I did with my code above; which does work. If you publish your session variable you can use it client side also which you can see in my code above: {grid.Object}.gridFilterSet(userfilter)
                          This type of filter can be removed by "clear search criteria" but you can also use {grid.Object}.gridBaseFilterSet(userfilter) which shouldn't be able to be cleared.

                          Comment

                          Working...
                          X