Re: Best practices for sortable columns



Following on from 's message. . .
I have several forms that display information from the database after
users log in. I would like the column titles to be sortable so that
when the user clicks on a column heading, the data re-displays in
sorted order of that column. Next time they click on it, it toggles
the order from ascending to descending, and then back to ascending
again.

Since I have many forms and each form has different columns, I was
wondering if there was a method that would be better than a brute force
approach. What are the best practices for this functionality?

Thanks!



ANSWER No 1
You may have noticed that you don't often see this style of UI in web pages. The main reason is that users need to be educated in how to use the method and (even with systems they use everyday for years) don't seem to cotton on very quickly to the tricks often available with column headings. The secondary reason is the delayed response when requesting a new database query and web page. "I just clicked on the heading hoping it would do something useful but I can't see any effect".

So web pages tend to use the more clunky (but (a) perfectly valid and (b) much more obvious) method of a drop down box(es) saying something like
Sorted by [Name v] [x] Ascending [go]


ANSWER No 2
You _may_ find search a more productive method than sort+browse. Depending on the nature of your data and the calibre or your audience you _may_ want to take them through a menu of
* - select this way
* - select that way
* - select the other way
It is really really really REALLY important to get all users actually using the system on their own without either giving up or making a hash or trying to get technical support. After all you (or perhaps the system designer) should know what people want to use the system for and farting around with every column under the sun is a waste of everybody's time. Proper analysis should reduce "I want to look at the data" to "which jobs are late" or "which of my jobs are late" or "my jobs" or "job No X".


ANSWER No 3
There are two steps to displaying lists
(1) Selecting from the database
(2) Displaying a table of results

Item 2 is easy to package. 2-dim array to 2-dim table with column-based function for say converting dates and adding links.

Item 1 can normally be done with one or two switch structures. These tend to be pretty obvious when looking at the code and pretty specific to the option chosen.
eg
switch (sortmode) {
case 'name'
$fields = 'name,age,status';
$where = '';
$sort = 'name';
....
}
and these variables get stuffed into a select.

What I personally have done is to create a class which takes a SQL statement to fetch X records and then (as required) displays them with all sorts of column variations and headings. The SQL is 'hand crafted' but the display is half a dozen bog-standard lines.



So, to summarise: You might want to rethink your UI. Displaying is a mechanical thing that can be stuffed into a class[1] but setting-up SQL is more easily done in-line with a few switches.


Well, that's /my/ experience.


[1] With the benefit that each time you add functionality to the class you can re-use it on other projects.

--
PETER FOX Not the same since the poster business went to the wall
peterfox@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk>
.



Relevant Pages

  • Re: Streets & Trips 2009. Same ole
    ... with MS typically displaying their locations a good 50 miles ... campground; but one campground after another displayed the same ... My main complaint is the change in holding down left mouse button ... switch around. ...
    (rec.outdoors.rv-travel)
  • Re: Using Columns in a Crosstab Query as fields in another query
    ... that column heading comes from the value of a show ID field. ... Here's the SQL for the crosstab query: ... And here's the SQL for the bonus points query: ...
    (microsoft.public.access.queries)
  • Re: 3vl 2vl and NULL
    ... Take a simple screen for displaying a person's first name, last name, all values for e-mail address and first names of all children. ... We can surely model this data with multiple relations and we could also use a single relation with nested relations to model it if we add in data for ordering, but we cannot model this view of the data with an SQL view. ... We could potentially have a cartesian product view that includes all of the data for the screen, but it does not use the same data model as the view. ... The data model for the screen is not in 1st normal form and SQL requires 1NF. ...
    (comp.databases.theory)
  • Re: detail table display order
    ... Change your SQL to read as follows: ... > Am displaying data from a detail table in a dbgrid. ... > Standard, 2 ... > select * from bracket ...
    (borland.public.delphi.database.ado)
  • Re: Report based on Crosstab with dates changing daily
    ... The following is my SQL: ... "Duane Hookom" wrote: ... > Set the column heading expression to: ... > To create column labels in your report, use text boxes with control sources ...
    (microsoft.public.access.reports)

Loading