Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
Unamailer #1
Prev/Next Sorting
I have a utility that allows a user to search for a record, based on several
criteria. Once that criteria is returned, it only displays 25 records at a
time. For example, 1-25 of 127. I can navigate that just fine (1-25, 26-50,
etc). However, I am displaying three columns of information, such as program
name, date, and error code. The defualt sort order is by date in ascending
order. I want the user to be able to sort by each field in both ascending or
descending order. I have a ^ (up arrow) and v (down arrow) graphic button
beside each column heading to allow the user to select ascending or descending
in that order. Problem is, when I click on one of the column headers to sort
by that field, or when I click on one of the ^ or v symbols to sort ascending
or descending, it sorts only that page of results (records 1-25), not the
entire record set (1-127). How do I get it to completely re-run the query and
re-sort all of the records? I am at an end..... Any help would be
appreciated.
Unamailer Guest
-
Prev email
re fonts and styles and statwide setting message -
Next/Prev Buttons
Hey All, I have a quick question, that should be pretty simple, hopefully somebody can push me in the right direction. Alright, i'm creating a... -
Prev and Next Links
I have a datagrid control that is paging enabled. Problem is the Next and Prev text appears but are not links.. Any ideas? -
first-prev-next-last using PHP
Adi Schwarz wrote: > AR John wrote: >> >> Could anybody tell me how it is possible to show the result with 30 >> items each time having... -
newbie: prev/next list
On my pages I always have a previous button and a next button. The files are put in order. like this: index.php preface.php plants.php ... -
-
Unamailer #3
Re: Prev/Next Sorting
JonathanBigelow: Thanks for the reply! I have cut out some of the unnecessary
code to make it easier to read. Here goes:
<CFPARAM name="URL.sortOrder" default="DESC">
<CFPARAM name="URL.sortItem" default="AbendDate">
<CFPARAM name="URL.firstRec" default="1">
<CFPARAM name="URL.lastRecord" default="0">
<CFQUERY name="getRecords" datasource="FCSJaxAbends">
SELECT GeneralInfo.*
FROM GeneralInfo
WHERE GeneralInfo.JobName LIKE '%#FORM.jobName#%'
ORDER BY GeneralInfo.#COOKIE.sortItem# #COOKIE.sortOrder#
</CFQUERY>
<CFSET count = getRecords.recordcount>
<CFSET Last = URL.firstRec + 24>
<CFIF Last GT count>
<CFSET Last = count>
</CFIF>
<H1>Search Results</H1>
<P>There were <CFOUTPUT>#count#</CFOUTPUT> records matching your criteria.</P>
<TABLE width="600" border="0" cellspacing="0" cellpadding="0" align="left"
valign="top">
<TR>
<TD colspan="3">
<TABLE align="left" border="0" cellspacing="0" cellpadding="0" width="100%">
<TR>
<TD style="border-bottom: 1px solid #000000;"
class="title"><CFOUTPUT>Displaying records #URL.firstRec# to #Last# of
#count#</CFOUTPUT></TD>
<TD style="border-bottom: 1px solid #000000;" align="right">
<CFIF URL.firstRec GT 1>
<CFSET newFirstRec = URL.firstRec - 25>
<CFIF newFirstRec LT 1>
<CFSET newFirstRec = 1>
</CFIF>
<CFOUTPUT><A href="resAll.cfm?firstRec=#newFirstRec#">Previous
Page</A></CFOUTPUT>
<CFELSE>
Previous Page
</CFIF>
<CFSET newFirstRec = URL.firstRec + 25> |
<CFIF newFirstRec LTE count>
<CFOUTPUT><A href="resAll.cfm?firstRec=#newFirstRec#">Next
Page</A></CFOUTPUT>
<CFELSE>
Next Page
</CFIF>
</TD>
</TR>
</TABLE>
</TD>
</TR>
<TR style="color: #003399; font-weight: bold;">
<TD style="border-bottom: 1px solid #000000;">
JobName
<A href="resAll.cfm?sortItem=JobName&sortOrder=DESC"> <IMG
src="/fcsjax/images/DESC.gif" border="0" width="8" height="8" alt="Sort in
Descending Order"></A><A href="resAll.cfm?sortItem=JobName&sortOrder=ASC">< IMG
src="/fcsjax/images/ASC.gif" border="0" width="8" height="8" alt="Sort in
Ascending Order"></A>
</TD>
<TD style="border-bottom: 1px solid #000000;">
Abend Date
<A href="resAll.cfm?sortItem=AbendDate&sortOrder=DESC "><IMG
src="/fcsjax/images/DESC.gif" border="0" width="8" height="8" alt="Sort in
Descending Order"></A><A
href="resAll.cfm?sortItem=AbendDate&sortOrder=ASC" ><IMG
src="/fcsjax/images/ASC.gif" border="0" width="8" height="8" alt="Sort in
Ascending Order"></A>
</TD>
<TD style="border-bottom: 1px solid #000000;">
Abend Code
<A href="resAll.cfm?sortItem=AbendCode&sortOrder=DESC "><IMG
src="/fcsjax/images/DESC.gif" border="0" width="8" height="8" alt="Sort in
Descending Order"></A><A
href="resAll.cfm?sortItem=AbendCode&sortOrder=ASC" ><IMG
src="/fcsjax/images/ASC.gif" border="0" width="8" height="8" alt="Sort in
Ascending Order"></A>
</TD>
</TR>
<CFOUTPUT query="getRecords" startRow="#URL.firstRec#" maxrows="25">
<TR>
<TD><A
href="javascript:self.location='inProgress.cfm?Abe ndNumber=#AbendNumber#&Jobname
=#JobName#&inProgress=search';">#JobName#</A></TD>
<TD>#DateFormat(AbendDate, 'mm/dd/yyyy')#</TD>
<TD>#AbendCode#</TD>
</TR>
</CFOUTPUT>
<TR>
<TD colspan="3"> </TD>
</TR>
<TR>
<TD colspan="3" align="right">
<HR>
<CFOUTPUT><A href="http://#HTTP_HOST#/fcsjax/">Back to Main
Page</A></CFOUTPUT> | <A href="schAll.cfm">Search for Another Record</A>
</TD>
</TR>
</TABLE>
Unamailer Guest
-
-
OldCFer #5
Re: Prev/Next Sorting
Why are you using Cookie variables in your query, when all of the variables I see, for sorting, are URL scope?
OldCFer Guest
-
Unamailer #6
Re: Prev/Next Sorting
OldCFer: Sorry...I left that part out when I was copy/pasting the neccessary
code. Guess I was in too big of a hurry. Anyhoo...the following two lines
should go after the four CFPARAM statements: <CFCOOKIE name='sortOrder'
value='#URL.sortOrder#'> <CFCOOKIE name='sortItem' value='#URL.sortItem#'>
Thanks for the reply!!
Unamailer Guest
-
Unamailer #7
Re: Prev/Next Sorting
Okay....nevermind....figured out a solution. I am not sure if it is the most
efficient way or not, but it works. In the above code, I changed the lines
that contain the Prev/Next links to read as follows. <CFOUTPUT><A
href='resAll.cfm?firstRec=#newFirstRec#&sortOr der=#COOKIE.sortOrder#&sor
tItem=#COOKIE.sortItem#'>Next Page</A></CFOUTPUT> Same for the Previous Page
line.
Unamailer Guest



Reply With Quote

