PDA

View Full Version : Search/filter grid - multiple fields



lwalling
6 Jan 2011, 9:44 AM
Is there a way to search an entire grid, not just one field?

My code to filter by one field:

myGrid.getStore().filter([{
property: 'case_id',
value: sVal,
anyMatch: true,
caseSensitive: false
}]);

steffenk
6 Jan 2011, 10:01 AM
use a custom filterBy function.

lwalling
6 Jan 2011, 1:11 PM
I'm not sure how to create a filterBy function. Very new to ExtJS.

moegal
6 Jan 2011, 1:20 PM
Here is one I am working on now.



this.getComboData = function(name, fieldset){
var theStore = combostore;
var id = theStore.findBy(function(record) {
if (record.get('name') == name && record.get('fieldset') == fieldset){
return true;
}
});
if (id == -1) {
return false;
}else{
return true;
}
};


It currently returns true or false but will return the id or even some json.

Marty

muliyono.lu
17 Jan 2013, 3:53 AM
store.filter([
{
property : 'name',
value : 'Ed',
anyMatch : true, //optional, defaults to true
caseSensitive: true //optional, defaults to true
},

//filter functions can also be passed
{
fn : function(record) {
return record.get('age') == 24
},
scope: this
}
]);