View Full Version : filter by surname and firstname

23 Nov 2011, 2:12 AM
I got a search which filter my grid by firstname
What do I need to do to make it filter by firstname or lastname?

search: function(searchValue) {
this.store.filter('firstName' , searchValue);

23 Nov 2011, 3:07 AM
I assume you are using local filtering? If so, take a look at the documentation for filter()

It shows how you can specify an filter function with some custome logic like comparing two fields with the desired value.

23 Nov 2011, 4:17 AM
Could you give an example? :P

23 Nov 2011, 6:56 AM
Uhm, I cannot make a clearer example then the one in the documentation I think. Did you take a look? What was unclear?

23 Nov 2011, 3:00 PM
I think using filterBy might be a little simpler. Something like this:

search: function(searchValue) {
this.store.filterBy(function(record) {
return record.get('firstName') === searchValue || record.get('lastName') === searchValue;