[drupal-devel] [feature] Ajax Tablesorting

Thox drupal-devel at drupal.org
Wed Aug 31 23:11:37 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:   Thox
 Status:       patch (code needs review)

I haven't tested the patch, only glimpsed through it for now.


The JS-side seems fine. I'm a little curious why tablesortAutoAttach()
does all the hard work, I imagined the tablesort object could do that
for itself.


+1 on the concept.




Thox



Previous comments:
------------------------------------------------------------------------

Wed, 31 Aug 2005 22:39:36 +0000 : Steven

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.




------------------------------------------------------------------------

Wed, 31 Aug 2005 23:04:38 +0000 : Steven

Attachment: http://drupal.org/files/issues/jstablesort_0.patch (13.25 KB)

Missed a table in statistics.module ;).







More information about the drupal-devel mailing list