Alpha DevCon 2018
Results 1 to 4 of 4

Thread: setFilter() help needed

  1. #1
    "Certified" Alphaholic mikeallenbrown's Avatar
    Real Name
    Mike Brown
    Join Date
    Nov 2009
    Location
    United States
    Posts
    1,529

    Default setFilter() help needed

    My setFilter() method isn't filtering the way I expected. Below is the code I am using. Where am I going wrong?

    The filter should return list rows where xMLSent_D is 'F' and Status is not 'Active'.

    Code:
    var lObj = {dialog.object}.getControl('workingList');
    
    lObj.setFilter(
    	{
    		xMLSent_D: RegExp('F','i'),
    		Status: function(val){
    			if(val == 'Active'){ return false; } 
    			else { return true; }
    			}
    	}
    );
    I was trying to follow the example from documentation: https://www.alphasoftware.com/docume...r%20method.xml
    Mike Brown - Contact Me
    Programmatic Technologies, LLC
    Programmatic-Technologies.com
    Independent Developer & Consultant

  2. #2
    Member jgrannis's Avatar
    Real Name
    Jeff Grannis
    Join Date
    Apr 2016
    Location
    New Iberia, LA
    Posts
    234

    Default Re: setFilter() help needed

    I am not 100% sure but I believe the documentation is misleading (or just wrong).
    The documentation says in a comment in the code: "//filter on the Name starts with an "E" and the Age is between 18 and 65 - note the value of "Age" gets passed into the function."
    However, I believe my use of this has always ended up on it being an "OR" type search on the 2 criteria rather than an "AND". I don't know if that is what you mean by "isn't filtering the way I expected".

    Would this give results more like expected:

    Code:
    lObj.setFilter(function(data){
    		if(data.xMLSent_D == 'F' && data.Status != 'Active') return true; 
    		else return false;
    	}
    );
    Last edited by jgrannis; 12-29-2017 at 09:54 AM.

  3. #3
    Alpha Software Employee Beta Spark's Avatar
    Real Name
    Sarah Mitchell
    Join Date
    Jul 2015
    Posts
    390

    Default Re: setFilter() help needed

    Quote Originally Posted by mikeallenbrown View Post
    My setFilter() method isn't filtering the way I expected. Below is the code I am using. Where am I going wrong?

    The filter should return list rows where xMLSent_D is 'F' and Status is not 'Active'.

    Code:
    var lObj = {dialog.object}.getControl('workingList');
    
    lObj.setFilter(
    	{
    		xMLSent_D: RegExp('F','i'),
    		Status: function(val){
    			if(val == 'Active'){ return false; } 
    			else { return true; }
    			}
    	}
    );
    I was trying to follow the example from documentation: https://www.alphasoftware.com/docume...r%20method.xml
    Hello Mike,

    FYI - We recently merged the A5.ListBox doc with the List Object documentation. You can find the setFilter method here: https://www.alphasoftware.com/docume...ilter%20method
    Sarah Mitchell

    Looking for answers? Try our documentation.
    If you can't find something, let us know!

  4. #4
    "Certified" Alphaholic mikeallenbrown's Avatar
    Real Name
    Mike Brown
    Join Date
    Nov 2009
    Location
    United States
    Posts
    1,529

    Default Re: setFilter() help needed

    Quote Originally Posted by jgrannis View Post
    I am not 100% sure but I believe the documentation is misleading (or just wrong).
    The documentation says in a comment in the code: "//filter on the Name starts with an "E" and the Age is between 18 and 65 - note the value of "Age" gets passed into the function."
    However, I believe my use of this has always ended up on it being an "OR" type search on the 2 criteria rather than an "AND". I don't know if that is what you mean by "isn't filtering the way I expected".

    Would this give results more like expected:

    Code:
    lObj.setFilter(function(data){
    		if(data.xMLSent_D == 'F' && data.Status != 'Active') return true; 
    		else return false;
    	}
    );
    Thanks Jeff! That worked beautifully.
    Mike Brown - Contact Me
    Programmatic Technologies, LLC
    Programmatic-Technologies.com
    Independent Developer & Consultant

Similar Threads

  1. List setFilter AND or OR
    By jgrannis in forum Mobile & Browser Applications
    Replies: 1
    Last Post: 07-18-2017, 05:31 PM
  2. Replies: 2
    Last Post: 03-23-2017, 12:58 PM
  3. Problem With Dual Criteria Filter Using SetFilter()
    By pbc83 in forum Mobile & Browser Applications
    Replies: 2
    Last Post: 06-02-2015, 12:06 PM
  4. Serious Help Needed
    By Jared Sutherland in forum Web Application Server v6
    Replies: 1
    Last Post: 05-13-2005, 02:03 PM
  5. Help needed
    By Debbie Bartlett in forum Alpha Five Version 5
    Replies: 15
    Last Post: 01-02-2003, 08:05 AM

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
  •