Give your website visitors a method to sort database-driven dynamic data on your result pages. In this tutorial, I will demonstrate how to add links to your column headers that allow for sorting.
You can follow along with my examples using the same preset. Once you learn this concept, it can be applied to other pages.
Before applying the sort server behavior, you need to remove any sorting previously applied to the recordset.
In Bindings, doubleclick Recordset (WADAproducts).
This opens a Recordset dialog with the recordset that was automatically generated using the DataAssist wizard.
In this tutorial, the recordset is displayed in Simple mode. To remove any sorting previously applied to the recordset, go to Sort and select None.
However, if your recordset is displayed in Advanced mode, you will want to remove any ORDER BY clause.
When you are done with this step, click Test to test your SQL statement.
Now it's time to add links to column headers so that data can be sorted. To trigger the sort, a link needs to be added to the current page for each column header you want to sort.
Select a column header. (For example: Name)
Then select the link folder icon in the Properties panel.
With the Select File box open, select the radio button labeled File system. (In some versions, Dreamweaver automatically opens the file system.)
Choose the products_results file from the admin folder.
Type sort in Name and ProductName in Value. (The entry in Value should match the database column name you want to sort.)
When finished, click OK.
The final step in this section is to add a QueryString Binding.
The QueryString Binding option makes the parameter available for triggering the sort and allows you to filter URL parameters for more complex sorting operations.
Go to the Bindings panel and click +.
Select QueryString Binding which opens the Filtered URL Parameter box. Type sort into Parameter name.
Save the page. (Ctrl or Cmd + S)
Now that the page set-up is complete, we'll add the sort server behavior next.
From the Server Behaviors panel, click +.
Scroll down to WebAssist, then DataAssist, and click Sort.
When the Sort dialog box opens, click the Trigger lightning bolt icon.
After the dialog box opens, expand the QueryString Data binding and choose sort.
Back in the Sort dialog box, make sure WADAproducts is selected for your recordset.
Because DataAssist has already created the correct Session variable, leave the default entry.
To toggle the sort between ascending and descending, check the Toggle sort on subsequent visits box.
Under Sorting in the dialog box, click +.
Then click the Column lightning bolt icon.
When the dialog box opens, select sort under QueryString Data.
Choose the Sort order from the available options. (For example: Ascending)
Save your page. (Ctrl or Cmd + S)
Preview the page in your browser. Now you can click on the Name column header to sort the data in your table.
Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.
These out-of-the-box solutions provide you proven, tested applications that can be up and running now. Build a store, a gallery, or a web-based email solution.