Results 1 to 3 of 3

Thread: Can't filter multiple extjs grid columns

  1. #1
    Sencha User
    Join Date
    Jun 2012
    Posts
    35
    Vote Rating
    1
      0  

    Default Can't filter multiple extjs grid columns

    To filter one grid column I use:
    Code:
    store.filter({      
        property: 'first_name',    
         anyMatch: true,     
        value   : this.getValue()  
        });

    Now I need to search multiple fields at once, something like:

    Code:
          var filters = [ 
       new Ext.util.Filter({  
      property: "first_name",
     anyMatch: true, 
    value: this.getValue()  
      }),  
      new Ext.util.Filter({ 
      property: "last_name",
     anyMatch: true, 
    value: this.getValue()  
     }) ];
      store.filter(filters);

    The weird thing is that in both cases, only single search works


    EDIT

    Now I tried:

    Code:
    store.filter([{property: "first_name", anyMatch: true, value: this.getValue()},{property: "last_name", anyMatch: true, value: this.getValue()}]);

    it worked but as an AND condition, like when user types 'ma' .. it retrieved the names but only those contains 'ma' in both first and last names. I need it to be OR. How can I do this ?

  2. #2
    Sencha User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,026
    Vote Rating
    1367
      0  

    Default

    Trying using filterBy and pass in a function where returning true will keep the record in the store, false will filter it out of the store.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  3. #3
    Sencha User atmiyadas2014's Avatar
    Join Date
    Aug 2014
    Posts
    31
    Vote Rating
    1
      0  

    Default Problem Solve Using filterBy

    Code:
     store.filterBy(function(record)
    {                   
           var name = record.get('FirstName').toLowerCase() + " " + record.get('LastName').toLowerCase();                             
           if (name.indexOf(queryString) != -1)   
                 return record;                           
    }

Tags for this Thread

Posting Permissions

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