[Zope] sorting a table

Thomas B. Passin tpassin@mitretek.org
Thu, 3 Jan 2002 08:16:24 -0500


You can do this on the server or in the client.  To do it on the server,
when the user clicks on the column header you call a different ZSQL query
that returns the data with the sort order you want.  Of course, you have to
wait for the results and you put more load on the server and database than
if you did it on the client.

To do it on the client, you have to decide if you want to support standard
browsers or just newer ones.  In either case you have to use javascript (I'm
not considering using java applets or plugins).  With IE5.5 and Mozilla, you
can do it by using the DOM (Document Object model), with IE5.5 you could
write to the table element using Microsoft's version of DHTML.

To work with earlier version browsers (i.e., Netscape version 4+), you need
to use frames.  Send the data in javascript arrays in one frame (or the HEAD
element of the frameset), then write the table in the display frame using
document.write() to generate the HTML for the table based on the data stored
in the javascript arrays.

To resort the data, you would rewrite the frame.

Cheers,

Tom P

[Lucas Vogel]

I have a DTML method that calls a Z SQL Method and places the results into
an
HTML table. What I would like to do with the table is make the column
headers
sort the results in ascending and descending order when they click on the
link. I haven't really seen any Howtos or anything in the Zope book that
describes or explains what I'm trying to do. If someone could help me with
this I'd appreciate it.