PDA

View Full Version : Possible bug in Store.filter() method: passing in an array of fields



caltheon
18 Jun 2010, 2:51 PM
I am having a problem with the Store's filter method.


var text = Ext.getCmp('userfilter').getValue();
var regex = new RegExp(text, "i");
availableUsersDs.filter('name', regex);


Works fine, however,



var text = Ext.getCmp('userfilter').getValue();
var regex = new RegExp(text, "i");
var fields=new Array("name","userId");
availableUsersDs.filter(fields, regex);

Throws an exception in ext-all.js

The error is thrown in this method


createMultipleFilterFn: function(filters) { return function(record) { var isMatch = true;
for (var i=0, j = filters.length; i < j; i++) { var filter = filters[i], fn = filter.fn, scope = filter.scope;
isMatch = isMatch && fn.call(scope, record); }
return isMatch; }; },

the line that throws the error is
isMatch = isMatch && fn.call(scope, record);
fn.call is not a function (the value of fn at this point is a boolean 'false')

Any ideas what the problem is? Do you HAVE to provide a filter function if you are filtering on more than one field?

ucoxk
16 Nov 2011, 4:03 AM
Try this it works for me
var filters = new Array();
function property(pro,val) {
this.property=pro;
this.value = val;
}

var regex = new RegExp(text, "i");

var nameOb = new property("name", regx);
filters.push(nameOb);
var idOb = new property("userId", 2);
filters.push(idOb);
store.filter(filters);

In this way you can filter store on multiple columns