Question
I want to present the search result as the following: If the user clicks on a button (or a link) in the header, the data will be sorted according to the value of that particular variable. How could I accomplish this? (The following table is dummy. Please do not click the sorting link).
| Item ID descending ascending | Sample size descending ascending | Mean descending ascending | Point Biserial descending ascending | Discri- mination descending ascending |
|---|---|---|---|---|
| 1 | 13 | .13 | .01 | -.08 |
| 2 | 13 | .11 | .13 | .1 |
| 3 | 13 | .18 | -.07 | -.16 |
| 4 | 13 | .02 | -.21 | -.09 |
| 5 | 13 | .96 | .23 | .18 |
| 6 | 12 | .69 | .13 | .16 |
| 7 | 12 | .76 | .12 | .13 |
| 8 | 12 | .13 | .43 | .28 |
| 9 | 12 | .81 | .21 | .23 |
| 10 | 12 | .5 | -.08 | -.29 |
Answer
You can create different links for different sorting functions by specifying the database, the layout, the action, the sorting order,and so on. The following is an example for sorting the Item ID field in a descending order. It is important to note that the whole thing must be in one line. I put them in different lines just for clarity.
http://URL/folder_name/ FMPro?-db=databasename &-format=SearchResults.htm &-lay=layout%20%231 &-max=all &-SortField=itemid &-SortOrder=descending &-op=eq &-find
The meanings of the preceding code is explained in the following:
| Syntax | Description |
|---|---|
| http://URL/folder_name/ | Specify the server's URL and the folder in which you store the SearchResults.html |
| FMPro?-db=databasename | Specify the name of the database |
| &-format=SearchResults.htm | Specify the page to display after sorting. Usually it should be the same page in which the table is displayed. |
| &-lay=layout%20%231 | Specify the layout name from which the database pulls data. |
| &-max=all | Specify how many records you want to display at once. |
| &-SortField=itemid | Specify that the field to be sorted is ItemID |
| &-op=eq | Specify the comparison operator as "equal" |
| &-find | Specify the action as "find" |
You can repeat the same procedure to create sorting links for other fields.
