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.
Click OK.
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.
Click Parameters.
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.
Click OK.
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.
Click OK.
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.
Click OK.
Choose the Sort order from the available options. (For example: Ascending)
Click Finish.
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.
Comments will be sent to the author of this tutorial and may not be answered immediately. For general help from WebAssist, please visit technical support.
Sign in to add commentsYour 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.
JBWebWorks: 9 Years, 10 Months, 6 Days, 2 Minutes ago
Wanted to know how to sort on multiple columns i.e. productName and productPrice with a single click?
Team WebAssist: 9 Years, 10 Months, 5 Days, 19 Hours, 1 Minute ago
JBWebWorks: This tutorial shows you how to sort on productName. You'd repeat the steps for each column you want to allow the clickable sorting for.
Web Designer Troy: 9 Years, 8 Months, 1 Week, 3 Days, 11 Hours, 48 Minutes ago
Is there a way to anchor to part of a page after the sort and still maintain the toggle? The URL parameter : "...myfile?sort=id#someanchor..." works, but kills the toggle option.
(I'm trying to avoid Javascript.)
erinlima318673: 6 Years, 7 Months, 6 Days, 19 Hours, 54 Minutes ago
Is there a way to make this work with a customer-facing results page, showing product images and descriptions in a repeat region? I want to allow my customers to sort the results by price ascending and descending, and my make. I have gone through the tutorial umpteen times and can't get the results in the repeat region to change at all.