Alpha Video Training
Results 1 to 3 of 3

Thread: Filter List from Cache

  1. #1
    VAR
    Real Name
    Andy Meer
    Join Date
    Mar 2005
    Location
    Atherstone UK
    Posts
    452

    Default Filter List from Cache

    Hi Guys

    I need some help on my Javascript the code below; which filters my List Product (held in Cache) with the value held in the vSearchFor variable; this code works just fine but the text I search for has to be the whole name for example

    vSearchFor = 'Aspire Pockex' what i would like the users to be able to do is use any string for example
    vSearchFor = 'Pockex' or vSearchFor = 'Pock' and this would return any instances of Pockex or Pock.

    Kind Regards
    Andy
    Code:
    var vSearchFor = {dialog.object}.getValue('Search')
    var _onOffline = function() { 
    
    }; 
     var _onServerNotAvailable = function() { 
    ;
    };
    var _onSuccess = function(data) { 
    var ops = {columnCount: 3};
    {dialog.object}.setListColumnsAndPopulate('Product',data,ops)
    
    ;
    };
    var _onFail = function() { 
    ;
    };
    
    var _filter = 'data.NAME == \''+vSearchFor+'\'';
    
    var _order = {'NAME' : 1};
    {dialog.object}.getFromDataCache('Products',_onSuccess,_onFail,_filter,_order,_onOffline,_onServerNotAvailable);

  2. #2
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,572

    Default Re: Filter List from Cache

    Is it a "like" search you want to do? If so, here's one way...

    Code:
    var _filter = function(data){
    	var s = data.NAME;
    	if(s !== null){
    		s = data.LASTNAME.toLowerCase();
    		var re = new RegExp(vSearchFor);
    		if(s.match(re)){
    			return true;
    		}else{
    			return false;
    		}
    	}else{
    		return false;
    	}		
    }
    First test for null values
    Then lower case the data coming in from the cache
    Then set up a new RegEx with the vSearchFor variable
    Then use match testing the data against the variable
    Last edited by Davidk; 06-15-2019 at 12:22 PM.

  3. #3
    VAR
    Real Name
    Andy Meer
    Join Date
    Mar 2005
    Location
    Atherstone UK
    Posts
    452

    Default Re: Filter List from Cache

    Hi David

    That worked

    Thanks so much for your help

    Kind Regards
    Andy

Similar Threads

  1. Replies: 4
    Last Post: 05-02-2019, 10:10 PM
  2. Client-Side Data Cache Editor - Filter on SQL?
    By trees-dk in forum Mobile & Browser Applications
    Replies: 7
    Last Post: 02-12-2016, 05:46 AM
  3. Populate List from Using Data Cache without population Columns
    By NormanRMouton in forum Mobile & Browser Applications
    Replies: 6
    Last Post: 02-10-2016, 04:59 AM
  4. Question re: list formatting using Client Side Data Cache
    By kenshap in forum Mobile & Browser Applications
    Replies: 2
    Last Post: 10-31-2015, 07:38 PM
  5. Filter Dropdown list in SEARCH part, based on grid filter
    By lgrupido in forum Application Server Version 10 - Web/Browser Applications
    Replies: 1
    Last Post: 03-28-2011, 05:05 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
  •