Get a Jumpstart with our Sample Apps
Results 1 to 2 of 2

Thread: Client-side filter on a List control with Lookup columns

  1. #1
    Member
    Real Name
    Jeff Grannis
    Join Date
    Apr 2016
    Location
    New Iberia, LA
    Posts
    125

    Default Client-side filter on a List control with Lookup columns

    I would like to use the listObj.setFilter method to filter a List control (let's call it list1) on the lookup columns.
    For instance, let's say I have the column's: ItemID, Price and then the lookup column: Description.

    The list is configured to store the data in localstorage. I can see the lookup column data stored in the data object but on a "child level".
    For example:
    {"data":[{"ItemID":"0101","Price":"0","__primaryKey":"0101","LookupDesc":{"Description":"SHARPENING STONE SET", etc....


    I'm starting with this code:

    Code:
    var listObj = {dialog.object}.getControl('list1');
    var searchFor = {dialog.object}.getValue('TxtBox_searchFor');
    
    listObj.setFilter(
        {
            Description: RegExp(searchFor,'i')
        }
    );
    Searching for "STONE" doesn't find anything.

    Just to check, if I change this part of the code:
    Code:
    listObj.setFilter(
        {
            ItemID: RegExp(searchFor,'i')
        }
    );
    And search for "0101", the list filters down to that row as expected.

    If I try,
    Code:
    var listObj = {dialog.object}.getControl('list1');
    var searchFor = {dialog.object}.getValue('TxtBox_searchFor');
    
    listObj.setFilter(
        {
            LookupDesc.Description: RegExp(searchFor,'i')
        }
    );
    The console log shows an unexpected token error concerning the "."

    Is it possible to filter a list on these types of lookup columns?

  2. #2
    Member
    Real Name
    Jeff Grannis
    Join Date
    Apr 2016
    Location
    New Iberia, LA
    Posts
    125

    Default Re: Client-side filter on a List control with Lookup columns

    Nevermind. As soon as I posted this question, I had a flash and remembered to filter with a function...

    So, this works (well, works for an "equals" type filter; not for a "contains"):

    Code:
    listObj.setFilter(function(data){
    	if(data.LookupDesc.Description == searchFor) return true; // yes, show this row
    		else return false; // no, hide this row
    });

Similar Threads

  1. Client Side Filter on a List Control
    By dfricke10 in forum Mobile & Browser Applications
    Replies: 1
    Last Post: 06-22-2017, 12:12 AM
  2. Client-Side List Filter
    By Scott B in forum Mobile & Browser Applications
    Replies: 3
    Last Post: 03-11-2017, 10:20 PM
  3. Replies: 2
    Last Post: 08-01-2016, 10:29 AM
  4. Clear client side filter on list control
    By rjackson@arach.net.au in forum Mobile & Browser Applications
    Replies: 3
    Last Post: 05-23-2015, 02:22 AM
  5. Client-Side Filter List Control initial load
    By TheSmitchell in forum Mobile & Browser Applications
    Replies: 2
    Last Post: 04-14-2015, 08:44 PM

Posting Permissions

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