1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    7
    Vote Rating
    0
    sshres is on a distinguished road

      0  

    Question Answered: Filter store data by 2 values for the same column

    Answered: Filter store data by 2 values for the same column


    Hi All,

    I am a newbie to ExtJS and have a question. How can I filter data in store by passing multiple values for the same column. The requirement is user wants to see data for two different status together. For eg. I have a column named 'Status'. I want to filter the data by passing values like this:
    property: status, value: "In progress"
    property: status, value: "Rejected"
    and so on...

    Thanks

  2. your question is bout store.filter ?
    store.filter("email", /\.com$/);
    check documentation, im not familiar with filtering but second argument seems to accept a regex u can use to make status equal to "in progress" or "Rejected"

    also filters accepts functions (check the store.filter documentation too)
    {filterFn: function(item) { return item.get("age") > 10; }}

    so maybe u can do something like
    return (item.get('status') == 'In progress' || item.get('status') == 'Rejected')

    or your question its bout loading records from server that correspond to "where status = 'in progess' or status ='rejected'"?

    (sorry for my bad english)

  3. #2
    Sencha User
    Join Date
    Dec 2011
    Posts
    224
    Vote Rating
    9
    Answers
    13
    dedoz will become famous soon enough

      0  

    Default


    your question is bout store.filter ?
    store.filter("email", /\.com$/);
    check documentation, im not familiar with filtering but second argument seems to accept a regex u can use to make status equal to "in progress" or "Rejected"

    also filters accepts functions (check the store.filter documentation too)
    {filterFn: function(item) { return item.get("age") > 10; }}

    so maybe u can do something like
    return (item.get('status') == 'In progress' || item.get('status') == 'Rejected')

    or your question its bout loading records from server that correspond to "where status = 'in progess' or status ='rejected'"?

    (sorry for my bad english)

  4. #3
    Sencha User
    Join Date
    Feb 2012
    Posts
    7
    Vote Rating
    0
    sshres is on a distinguished road

      0  

    Default


    Thanks. My questions was on store.filter and your solution worked!

  5. #4
    Sencha User
    Join Date
    Aug 2013
    Posts
    21
    Vote Rating
    0
    sivamurthy is on a distinguished road

      0  

    Default


    Hi All,
    I have to filter the sencha touch store with one property with multiple values, array of values will come dynamically.
    Ex: I have to filter the store for property name with values 'india','america','japan' but values will come dynamically.

    Please let me know how to filter the with above constraints.

    Thanks,
    siva.

  6. #5
    Sencha User
    Join Date
    Jan 2014
    Posts
    22
    Vote Rating
    2
    Answers
    1
    AkshayKalbhor is on a distinguished road

      0  

    Default a better solution than hardcoding the values in the store that was suggested.

    a better solution than hardcoding the values in the store that was suggested.


    You can use the below function when the values on which you want to filter are available in the form of an array.

    Here I have to filter the records on [1,4,5] which is the id's of selected records from a multiselect dropdown which is available in "filterIds".

    Code:
    filterGrid : function(filterIds) {		this$ = this;
    		if(filterIds.length <= 0) {
    				this$.removeFilter();
    		}
    		
    		if(filterIds.length != 0) {
    			this$.filterBy(function(record, id){
                                  // record is the individual record from the store.
    
    				var recordFlag = false;
    				Ext.each(filterIds, function(filter) {
    					if(record.get('quotaTypeId') === filter) {
    						recordFlag = true;
    					};
    				});
    			    return recordFlag;
    			}, this);
    		}
    	}