PDA

View Full Version : filtering Store by several fields



Flcn
6 Jul 2010, 12:59 AM
Hello ) i have one more problem/question

I have Store and Panel with toolbar and my own element.
in toolbar now i have 2 textfields:


items: [
{
xtype:'textfield',
name:'nameFileterField',
enableKeyEvents: true,
emptyText:'Name',
listeners: {
keyup: function(f){
myStore.filter('name',f.getValue(),true)
redrawElement(myStore.data.items)
}
}
},
{
xtype:'textfield',
name:'numberFileterField',
enableKeyEvents: true,
emptyText:'Number',
listeners: {
keyup: function(f){
myStore.filter('telephones',f.getValue(),true)
redrawElement(window.myStore.data.items)
}
}
}
]

all works fine
But if i input text in all textfields. Store filtering only by last 'inputet' textfield.
i know why it happens.
but can't find right way to prevent it. Please help to find solution how filter my store by few values.
i find way where i must collect filters in one place (array) and getValues of all filters when event fire

mitchellsimoens
6 Jul 2010, 6:57 AM
You should have a separate function. This function will grab the values of both fields and then filter it. You will also have to use the filterBy() function to create your own function since you will have 2 values to search with.

Flcn
7 Jul 2010, 3:42 AM
thanks.
but
I going some different way
i create function on evere filter ".createFilterFn"
and push it in array if it return true.
and after it put it in ".filter" first argument.
second is arg is unnecessary
all works fine.

but may be somebody know more simple way?