*Works in Dreamweaver 6 and higher, including CS3/CS4/CS5/CS5.5/CS6
Works in ASP VBScript, JSP, PHP/MySQL, and ColdFusion, all in one package
As with my other server behaviors, the Sort Repeat Region server behavior is designed to work hand-in-hand with existing Dreamweaver server behaviors, like the Recordset and the Repeat Region. This server behavior will enhance the core set of Dreamweaver server behaviors by adding a Sort function to arsenal. The server behavior assumes you are using standard Dreamweaver recordsets and repeat regions.
When you apply a repeat region to a table row, there is no easy way to sort the results according to the column heading. This server behavior can be applied to a table that has a repeat region on it. The server behavior will automatically create all the code necessary to have clickable links in place of the column headings that will order the recordset by that column. Another click will order in descending order.
Important: The pre-requisites to use this extension are as follows:
- Add a recordset to the page (Dreamweaver compatible recordset)
- Add a two-row table on the page that has the headings in the first row and the dynamic data in the second row.
- Add a repeat region to the second row.
With that in place, you can use the Sort Repeat Region server behavior. The steps to apply the server behavior are as follows:
1. Select your dynamic table on the page. The entire table should be selected. This can be done by clicking the <table> tag in the tag selector.
2. Open the server behavior panel and choose:
Server Behaviors >> Tom-Muck.com >> Sort Repeat Region
The interface looks something like this:
3. If there are any parameters (such as a search text field) enter them by name in the Keep These Parameters box. If there are none, leave it blank (the default). If you have more than one parameter, enter the parameters separated by commas, like this*:
*Note: PHP users have a checkbox option for "new method". This causes the server behavior to use $_GET and $_POST in the code instead of $HTTP_GET_VARS and $HTTP_POST_VARS. This works in PHP version 4.1.2. Parameters should still be listed in the field as the above Step 3 shows.
4. Choose the recordset and the default sort column. The recordset will be sorted based on the default column the first time the page is hit and if there are no clicks. You can also choose to have it sort in ascending or descending order by default.
5. The column names should reflect what is already in your table, but you can change the text of the heading links here if necessary.
6. Click OK and the server behavior will be applied, including the appropriate order-by clause in your SQL statement.
The server behavior can be applied once per page only.
NOTE: If you are using the Simple recordset, the recordset will not be editable in the Simple recordset dialog box any more -- always edit your recordset from the Advanced dialog box to avoid any problems.
NOTE: The server behavior works by using dynamic SQL. Therefore, it won't work with a stored procedure. It works well with standard recordsets created using tables or views.
The main extension page for Basic-Ultradev (http://www.basic-ultradev.com/extensions) uses the Sort Repeat Region extension. Since there are numerous search parameters on that page, I entered them as a list in the Parameters box, like this:
Each item is an actual form field on that page. That way, I was able to keep any relevant search info available to each click of a table heading.
Dreamweaver 8.0.2 and CS3 compatibility
If using Dreamweaver 8.0.2 or Dreamweaver CS3, the recordset will show up as a "TomListRecordset" in the Bindings and Server Behaviors panel. This is required because of severe bugs in Dreamweaver with dynamic SQL since the Dreamweaver 8.0.2 updater introduced these bugs. The new recordset has all the same properties as a Dreamweaver recordset, but has special code behind the scenes to allow previewing and bindings panel functionality that. The standard Dreamweaver recordset has bugs that prevent this in 8.0.2 and CS3. Recordsets work fine with the server behaviors in DW 6, 6.0.1, 7, 7.1, 8.0, and 8.0.1. NOTE: The JSP and ASP/JS versions are not compatible with Dreamweaver 8.0.2 or Dreamweaver CS3, but will work with DW 6, 7, 8.0, and 8.0.1.