Wondering if anyone has some ideas on how to approach a list with
columns that are sortable by clicking on the headers. Would like to
be able to sort asc or dec by clicking multiple times on the column
headers.
We're using fusebox, if anyone has sample code.
I create the links using this method:
/*
$inName is the column name that shows to the user
$inTarget is the target fuseaction
$inAbbrev is a one-character abbreviation that indicates which
column to sort by
$inCurOrder is the current column abbreviation
$inSortDir is the current sort direction
*/
method "makeColumnLink"($inName; $inTarget; $inAbbrev; $inCurOrder;
$inSortDir; $inTitle)
// If there is no sort direction or this is not the current
column, get the default
if ($inSortDir = "") | ($inCurOrder # $inAbbrev)
if (position($inAbbrev; "drcn") > 0)
$inSortDir := "0" // dates, ratings, conferences, notes
sorted descending by default
else
$inSortDir := "1"
end if
end if
if ($inCurOrder = $inAbbrev)
if ($inSortDir = "1")
$dirImage := "<img src=\"/images/sort_asc.gif\" width=\"9
\" height=\"5\" alt=\">\" />"
else
$dirImage := "<img src=\"/images/sort_desc.gif\" width=
\"9\" height=\"5\" alt=\"<\" />"
end if
// Current sort column link has the opposite of the current/
default direction
$inSortDir := string(1 - num($inSortDir))
else
$dirImage := ""
end if
return ("<a href=\"%1%;asc=%5%\" class=\"%2%\" title=\"%3%\">%4%%
6%</a>" % ($inTarget + $inAbbrev; choose($inCurOrder = $inAbbrev;
"sort-column"; ""); "Click to sort referrals by " + $inTitle;
$inName; $inSortDir; $dirImage))
end method
The column headers are created like this:
<%
// Build the base query string for the sort columns
$sortQuery := a4d.web.collectionItemsToQuery($attributes;
"nm;op;bst;bsz")
// Now build a link that ends with an empty ord attribute
$columnLink := fusebox.makeURL($attributes
{fusebox.conf.fuseaction}; build query string(*; "-a-" + $sortQuery;
"ord"; ""))
$sortColumn := choose($attributes{"ord"} # ""; $attributes
{"ord"}; "d") // default to date
$asc := $attributes{"asc"}
%>
<th>
<%=mylib.makeColumnLink("Date"; $columnLink; "d"; $sortColumn;
$asc; "date")%>
</th>
<th>
<%=mylib.makeColumnLink("School"; $columnLink; "s"; $sortColumn;
$asc; "school")%>
</th>
Along these lines, is it possible to sort a persistent rowset once
created? My thinking here is to simply resort the rowset I created to
display the rows.
The next release will have a RowSet.sort method.
Regards,
Aparajita
www.aparajitaworld.com
"If you dare to fail, you are bound to succeed."
- Sri Chinmoy | www.srichinmoylibrary.com
_______________________________________________
Active4D-dev mailing list
[email protected]
http://mailman.aparajitaworld.com/mailman/listinfo/active4d-dev
Archives: http://mailman.aparajitaworld.com/archive/active4d-dev/