PDA

View Full Version : textfield delayed keypress events



PCSpectra
15 Jan 2010, 8:07 AM
I have a textfield which is used to filter thousands of records. In the backend I used something like a SQL LIKE 'blah%' to incrementally display the results according to the match.

As it stands inside keypress of the textfield I update the store for the listbox which is to be filtered. Unfrotunately the event fires almost instananeously and it stresses the server just a little more than needed, so I would like to implement a second or 2 time delay between event firing.

http://www.extjs.com/deploy/dev/docs/

Does not appear to have a configuration option for setting delays in any key events, so the second option is to maybe use setTimout() however I think I will encounter errors in accessing the data store object from inside the context of a setTimeout() -- is there a work around???

Cheers,
Alex

aconran
19 Jan 2010, 5:58 PM
Ext provides you with a configuration buffer for addListener and on (buffer (http://www.extjs.com/deploy/dev/docs/?class=Ext.Element&member=addListener)).

This configuration gives you the exact behavior that you are looking for. Each time an event occurs it cancels out the latest pending event if they happen within the 'buffer' configuration.