PDA

View Full Version : store.filterBy



raj_plays
14 Jun 2010, 10:32 PM
Hi,
The filterBy method of Store class takes 2 params: record and id.
How can I pass a third param('val') to it?
I want to compare a field in each record to the third param.

This is what I have currently


store.filterBy(setPoint, this);

function setPoint(record, id, val)
{

}

evant
14 Jun 2010, 10:35 PM
The easiest way would be to use an anonymous function:



var val = 3;
store.filterBy(function(record, id){
console.log(val);
}, this);


Otherwise, you'll have to use createDelegate:



store.filterBy(setPoint.createDelegate(this, [val], true));

raj_plays
14 Jun 2010, 11:01 PM
Thank you for the swift response, evant

I tried the first solution. Error: 'console is undefined'
What is this console class, btw?

The second method works beautifully :)

evant
14 Jun 2010, 11:12 PM
http://getfirebug.com/

raj_plays
14 Jun 2010, 11:57 PM
Thank you, evant.
I understood after posting that console.log() can be replace by any function .