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

Searching list with logical checkbox

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

    Searching list with logical checkbox

    I am trying to recreate a list from a grid and am having trouble replicating a search functionality I had set up with the grid's logical controls, which worked like a charm in the grid. The grid contains clients who have some combination of four products: A, B, C, and D. Some clients have all four, some have one or two, and when a logical checkbox is selected for a product in the search part, only the clients who have that product remain in the grid. So, if you check A, everyone who has A is in the grid. If you check A and B, clients who have both A and B are in the grid (but, importantly, not clients who ONLY have A and B). Likewise, when you uncheck a product, it removes that particular filter, but leaves the rest. There is also a dropdown filter for geographic counties that could further filter the grid. Pretty basic stuff.

    The grid is linked to a SQL table where each product is defined with a bit field, true for yes and false for no. The following fires in an onChange event in the grid's search part for each logical field:
    Code:
    {grid.Object}.submitSearchForm();
    I am able to recreate this filter for a list when checking one of the logical checkbox filters, however, when I do multiple checks, or when I uncheck my logical checkboxes filters for the list, it works incorrectly. When unchecking, it filters the list so that it displays only clients who do not have the product. So, if I had checked A and B, then uncheck A, rather than displaying all clients who have B (but also might have other products), it displays clients who only have B and no other products at all. Likewise, it does not incorporate the dropdown county filter properly, only when used by itself to filter the list.

    The way I have set this up right now is by creating a unique Javascript Action for each checkbox (and the dropdown) called filter_A, filter_B, etc. which runs the action javascript 'Filter Records in a List Control' that only filters the one dialog and its corresponding field with search option 1. This action is set to run onChange.

    2020-03-07_20-00-43.png

    I have also tried combining the javascript actions into one 'Filter Records in a List Control' action and tying it all to an onClick event for a Filter button, but it doesn't help.

    I have also tried the built-in list search option, but that has an issue where if I check product A, it will yield results with customers who have ONLY product A, not all customers who have product A. Changing the list's 'multiple search criteria' from AND to OR does not fix it, but rather yields no results from the checkboxes.

    I am sure this is a fairly simple thing to fix but I can't quite grasp how. Thanks in advance for any assistance on this lengthy post.

    #2
    Re: Searching list with logical checkbox

    You'd need to provide a simple UX component using static data. There are too many properties and options involved to guess at what you have set.

    Comment


      #3
      Re: Searching list with logical checkbox

      Hi David, fair enough. However I am using server-side filters so I'm afraid I can't use static data to replicate it. I think I can pinpoint the issue and simplify the question though. Using the list debugger, I found that when the list is rendered, the following is generated:
      Code:
      {'page': 1, 'recordCount': 266, 'recordCountFormatted': '266', 'lastBreakValue': '', 'pageCount': 1, 'pageSize': 20, 'paginated': false, 'highlight': {}, 'whereClause': 'terminated = .f.', 'whereParameters': '', 'order': 'client_name', 'baseFilter': 'terminated = .f.', 'userFilter': '', 'sortColumn': 1, 'sortDirection': 'A'}
      When I check a filter (FA__user), the list state correctly changes to:
      Code:
      {'page': 1, 'recordCount': 256, 'recordCountFormatted': '256', 'lastBreakValue': '', 'pageCount': 1, 'pageSize': 20, 'paginated': false, 'highlight': {}, 'whereClause': 'terminated = .f.  AND  [B]fa_user = :FA_user_fa_user', 'whereParameters': 'True|||L|fa_user_fa_user\n',[/B] 'order': 'client_name', 'baseFilter': 'terminated = .f.', 'userFilter': '(fa_user = :FA_user_fa_user)', 'sortColumn': 1, 'sortDirection': 'A'}
      When I uncheck the 'FA_user' filter, the list state incorrectly changes to:
      Code:
      {'page': 1, 'recordCount': 10, 'recordCountFormatted': '10', 'lastBreakValue': '', 'pageCount': 1, 'pageSize': 20, 'paginated': false, 'highlight': {}, 'whereClause': 'terminated = .f.  AND  [B]fa_user = :FA_user_fa_user', 'whereParameters': 'False|||L|fa_user_fa_user\n',[/B] 'order': 'client_name', 'baseFilter': 'terminated = .f.', 'userFilter': '(fa_user = :FA_user_fa_user)', 'sortColumn': 1, 'sortDirection': 'A'}
      Is it possible that upon un-checking 'FA_user', the list reverts back to its original state instead of creating a WHERE parameter of FALSE for the field?

      Comment


        #4
        Re: Searching list with logical checkbox

        Then post a sample UX with a sample table with just a few records. It'd be far easier for you to create something to test than guess at how you'd put it together and the features used.

        Comment


          #5
          Re: Searching list with logical checkbox

          Ok no problem. Attached is a sample UX set up the same way. I'm not able to attach the sample SQL file here, but you can download it at: https://www.dropbox.com/s/weay401n2p..._test.sql?dl=0

          The UX is a little stripped down in design (no dynamic images in the list) but it functions the same way for testing and will show you what I mean about the undesirable logical checkbox filtering. If you have any issues accessing the SQL table from Dropbox please let me know. Thank you.
          Attached Files

          Comment


            #6
            Re: Searching list with logical checkbox

            Thanks for the sample... this makes it much easier.
            If, for a simple example, the HR checkbox is checked, then you want to see rows where hr_user is 1
            If, the HR Checkbox is not checked, then you want to see all rows. Not the rows where hr_users is 0. Is this right?

            If FA and HR are checked, then you want to see all rows where FA AND HR = 1. If HR is unchecked, then you want to see all rows were FA = 1. HR no longer matters.

            Comment


              #7
              Re: Searching list with logical checkbox

              Yes, that is exactly right on both examples. Thanks so much for looking into this, I appreciate your help.

              Comment


                #8
                Re: Searching list with logical checkbox

                its a "contains" search, might be the way to think about it...get the (checked) values into a string, use a js search function return true rows matching. I probably can't do it, lol but I think that would be an efficient method.
                NWCOPRO: Nuisance Wildlife Control Software My Application: http://www.nwcopro.com "Without forgetting, we would have no memory at all...now what was I saying?"

                Comment


                  #9
                  Re: Searching list with logical checkbox

                  Originally posted by gianfior85 View Post
                  Yes, that is exactly right on both examples.
                  You may have to roll your own search on this one since you're looking for just 1 of the possible 2 values of a checkbox. I'm not sure how you'd go about using Alpha's search dialogs to accomplish it.

                  This is just partial code. You're going to have to flesh the rest out.

                  Call one search function. You don't need to call an action to call a function... just call the function directly from the onChange event. This code looks after fa_user and hr_user if either, or both, are checked.

                  Code:
                  function searchList(){
                  
                  debugger;
                  
                  var params = '';
                  var listQry = '';
                  
                  var fa = {dialog.Object}.getValue('FA_user');
                  var hr = {dialog.Object}.getValue('HR_user');
                  var py = {dialog.Object}.getValue('Payroll_user');
                  var ht = {dialog.Object}.getValue('hosted_user');
                  
                  //fa
                  if(fa){
                  	params = '1|||N|faUser\n';
                  	listQry = 'fa_user = :faUser';
                  }
                  
                  //hr
                  if(params){
                  	if(hr){
                  		params = params + '1|||N|hrUser\n';		
                  		listQry = listQry + ' AND hr_user = :hrUser';
                  	}		
                  }else{
                  	if(hr){
                  		params = '1|||N|hrUser\n';		
                  		listQry = 'hr_user = :hrUser';
                  	}		
                  }
                  
                  {dialog.object}._filterList('CLIENT',listQry,'',params);
                  Is there a reason you want to use a Server-side search? This makes a call to the server for every search.

                  Comment


                    #10
                    Re: Searching list with logical checkbox

                    doing something similar, I use contains searching a concatenated field where in your case you would add in one and then use the built in AS function to search THAT field.
                    NWCOPRO: Nuisance Wildlife Control Software My Application: http://www.nwcopro.com "Without forgetting, we would have no memory at all...now what was I saying?"

                    Comment


                      #11
                      Re: Searching list with logical checkbox

                      David, many many thanks for that code. I can certainly flesh the rest out, but what is the proper syntax for calling the function in the onChange event? I thought it was simply entering the function name in the Javascript Attribute tab 'searchList()' but that doesn't seem to work. Sorry, I'm still learning some basic syntax in Alpha and otherwise.

                      As for it being server-side, you're correct that it doesn't need to be. I had set it up that way in trying to solve it with Alpha's search dialogs, and the client-side filtering dialog did not do anything.

                      Charles, thanks so much for your helpful input as well. I see what you're saying about it being a 'contains' search. I will have to look into a bit further how to execute what you described (I'm still a bit of a novice in this respect) but the principle behind it makes sense.

                      Comment


                        #12
                        Re: Searching list with logical checkbox

                        Originally posted by gianfior85 View Post
                        but what is the proper syntax for calling the function in the onChange event? I thought it was simply entering the function name in the Javascript Attribute tab 'searchList()' but that doesn't seem to work. Sorry, I'm still learning some basic syntax in Alpha and otherwise.
                        It is simply searchList();. If you have a Javascript function searchList() in your Javascript functions section, then it will run.

                        Comment


                          #13
                          Re: Searching list with logical checkbox

                          If you want to use a client-side filter, then use .setFilter. The data, by default, is not represented the same.

                          Code:
                          var lObj = {dialog.object}.getControl('client');
                          //search using a single function. data for the entire current row is passed into the function
                          lObj.setFilter(function(data){
                          	debugger;
                              if(data.fa_user == 'T' && data.hr_user == 'T') return true; // yes, show this row
                              else return false // no, hide this row
                          });

                          Comment

                          Working...
                          X