MAKE ALL YOUR TABLES SORTABLE by Stuart Langridge.
I am just going to mention a few lines from the article, because yes, my arse really is that lazy.
"It was pretty easy, that I was so amazed, that I had to share. Thus this post.
if you saw that table in a client-side application, you'd expect to be able to click on the headers and have the table sort, would you not? I know it always annoys me when you can't. A fair few web applications do allow this; most of them, which are pulling this data by submitting a SQL query to a relational database (an environment eminently suited to tabular data) implement this by resubmitting the whole page with something like ordercolumn=4 in the URL, and then adding an ORDER BY clause to their SQL query to return the data from the DB ordered by the specified column.
Resubmit the page? Just to sort data we already have? I'm sure we can do better than that.
Now, how to use it. To make a table of your choice sortable, there are three steps:
"
- Download the Javascript library
- Include the Javascript library, by putting a link to it in the HEAD of your page
- Mark your table as a sortable one by giving it a class of "sortable"
Tadah! And that's it. Let me end this with a quick note to Mr. Langridge.
TO STUART,
THANK YOU FOR BEING THE BRAIN BEHIND OUR LAZY ARSES.
JUST.
THANK YOU.
LOVE, ONE OF THE LAZY ARSES.
No comments:
Post a Comment