I can't take credit for this one... one of our readers actually sent me an
email with some ideas to modify our original Database Sort sample. Here's a excerpt from that email:
Rather than have two links, '+' and '-', you can remember the current state in a
variable and simply toggle between the two by clicking the field name itself. Or,
as I've done here, provide feedback as to the order by using arrows.
The code that was sent worked fine, but was a little complex and was obviously taken from
a highly modified version. I've simplified things a bit and incorporated both suggestions:
the simpler UI (just clicking on the field name) and the indicator arrows.
The simplified UI means that you no longer have to figure out if you should
click the + or the - next to each field name. Instead, you simply click on
the field name itself. The first click sorts ascendingly by the field
clicked. Once the table is sorted by the desired field, simply click the field
name again to reverse the order.
The current sort order is indicated by an arrow next to the field that the
table is currently sorted by. I've included both a text-based arrow and an image-based
one... you'd probably use only one or the other. I only include them both for illustration.
The images are something I just whipped up. I wanted them to stand out
which is the excuse I'll use for making them red. You'll probably want to use your own images,
but if you do want a copy of ours for any reason they can be found here: