PDA

View Full Version : Help with Store multiple filter



nicosk
21 Jul 2010, 10:34 AM
i have a store and i want to apply multiple filters on it. I have 2 toggle buttons and when they are pressed i want the filter to apply.

Button 1: Filter Finished
Button 2: Filter Scheduled

My code so far is:


,{
text:'Hide Scheduled',
enableToggle:true,
handler: function(){
if (this.pressed){
showScheduled = false;
if (showFinished == false){
liveScoreStore.filterBy(function(record,id){
return record.get('statusType') !== 'fin';
});
}
liveScoreStore.filterBy(function(record,id){
return record.get('statusType') !== 'sched';
});
}else{
showScheduled = true;
liveScoreStore.clearFilter();
}
}
}],


Instead when i click 1 button it works ok. But when i toggle the other one as well it applies the filter but resetting the filter set by button 1.

Hope my english are understandable

Thanks,
Nicos

Animal
21 Jul 2010, 12:00 PM
Use a function which calls the two filter functions.

nicosk
21 Jul 2010, 1:33 PM
I tried that, but i couldn't get it to work ok. Is it possible to give me a small example?

nicosk
23 Jul 2010, 2:58 AM
SOLVED.
I don't know if this the correct way to do it but it works for me :)


tbar: [{
text:'Hide Finished',
tooltip:'Hide Finished Games',
enableToggle:true,
handler: function(){
showFinished = !showFinished;
liveScoreStore.filterBy(function(record, id){
switch (record.get('statusType'))
{
case 'fin':
return (showFinished === true);
break;
case 'sched':
return (showScheduled === true);
break;
case '':
return false;
break;
default:
return true;
}
});
}