Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. Prev email
      re fonts and styles and statwide setting message
    2. 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...
    3. 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?
    4. 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...
    5. 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 ...
  3. #2

    Default Re: Prev/Next Sorting

    Can you attach your code please?
    JonathanBigelow Guest

  4. #3

    Default 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>&nbsp;|&nbsp;

    <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">&nbsp;</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

  5. #4

    Default Re: Prev/Next Sorting

    Did the above-attached code help any?
    Unamailer Guest

  6. #5

    Default 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

  7. #6

    Default 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

  8. #7

    Default 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#&amp;sortOr der=#COOKIE.sortOrder#&amp;sor
    tItem=#COOKIE.sortItem#'>Next Page</A></CFOUTPUT> Same for the Previous Page
    line.

    Unamailer Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139