[TYPO3-project-formidable] The poor man's AJAX pager

Gary Wong gary.wong at spingroup.com
Fri Aug 21 17:25:54 CEST 2009


I love using the AJAX functions on a search form to redraw list boxes 
and filters, then refresh a LISTER of results. But, as previously 
mentioned in other threads, the pager is not AJAX friendly.  Your search 
criteria will be reset if you click on a different page since the pager 
links use GET queries and the state information is not passed along.

Also, one of the most appealing uses of AJAX is to paginate results, 
which we do not yet have in Formidable.  Hopefully the authors will 
implement that in the future.

In the meantime, I've come up with a "poor man's" AJAX pager.  Thought I 
would share it with the list and maybe get some suggestions for 
improvements.

The entire code is in the pastebin: 
http://formidable.typo3.ug/pastebin/snippet/107.html

The idea is to put a LISTBOX control on the form that acts as the 
pager.  It's a dropdown box of page numbers. Onchange, this LISTBOX 
fires off an AJAX event that updates the LISTER.  The current page 
number is stored in the SANDBOX.  In the DATASOURCE, I use the 
little-known "beforeSqlExec" feature to override the LIMIT clause, 
creating the paging functionality.

My code creates the paging element as a LISTBOX of pages.  If someone 
can figure out how to create a set of page links, I'd like to see it! 

Also, this code requires an extra SQL call to count rows. If someone has 
any improvements, please submit to the mailing list!

Gary Wong




More information about the TYPO3-project-formidable mailing list