PDA

View Full Version : FIlter multiple values in store.



jesus.valencia
11 Mar 2015, 9:32 PM
Hello experts,

I have a bit of a problem I can't solve.

I have a Store and I want to filter multiple values, the thing is the multiple values may vary according to user selections, it may be only one value, or 5 or X.

I tried using addFilter, but I don't think is what I suppose to use, bacause it's like the values in the filter exclude each other.

My store has "cities". And the user selects "states". The cities Store has the states which they belong, if the user selects: TX, CA, FL, NY, I want that only the cities that correspond to that states are filtered.

The states I already got them in an Array, lest call it: states[].

I have also the CitiesStore with attributes like State, City, and so on.

Thanks in advance.

jesus.valencia
11 Mar 2015, 10:00 PM
store.filterBy( function(record){
if(valuesArray.indexOf(record.get('States')) > -1 ) {return true}else{return false}
});