[drupal-devel] [feature] Ajax Tablesorting

Steven drupal-devel at drupal.org
Wed Aug 31 22:49:23 UTC 2005


Issue status update for 
http://drupal.org/node/30150
Post a follow up: 
http://drupal.org/project/comments/add/30150

 Project:      Drupal
 Version:      cvs
 Component:    base system
 Category:     feature requests
 Priority:     normal
 Assigned to:  Steven
 Reported by:  Steven
 Updated by:   Steven
 Status:       patch (code needs review)
 Attachment:   http://drupal.org/files/issues/jstablesort.patch (12.93 KB)

This patch adds Ajax-based tablesorting to tablesort.inc. Note that this
is /not/ client-side sorting, which isn't that useful in Drupal as most
sortable tables are paged. Of course, given that it still requires a
round-trip to the server, the biggest advantage is in visual usability,
as only the table itself changes and not the entire page.


The way this is accomplished will probably strike you as very elegant,
or very dirty ;). In order to avoid patching up every instance of a
sortable table and providing a custom Ajax menu callback for each, I
made it so that inside theme('table'), the tablesort can cause the
table to be printed immediately and PHP to quit. This is triggered by
the GET variable 'tablesort', when set to the table's id.


So, the Ajax HTTP request visits the exact same page as the original
page, it only adds something to the URL which triggers this special
behaviour.


It works really well. In fact, the id-per-table wouldn't be necessary
if we restricted ourselves to one sortable table per page.




Steven




More information about the drupal-devel mailing list