Solved

paging

Posted on 2016-10-12
3
36 Views
Last Modified: 2016-10-13
Hi,

currently my paging output is like this:

<< Prev | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Next >>

but what I want is to display my paging something like this:

<< Prev | 1 | 2 | 3 | ..... | 9 | 10 | Next >>

because if I have 1,000's of records the paging will expand instead of having the first few pages and the last few pages.

Here's the code for paging:

  
  <cfif isDefined("URL.page") && #URL.page# neq ''>
	<cfset Defaultpage = #URL.page#>
<cfelse>
    <cfset Defaultpage = 1>
</cfif>

   <script language="JavaScript">
function PagingURL(pg)
 {
	
	$("#CQticketFrm").attr("action","FindCQTicket.cfm?page=" + pg);
	$("#SubTicket").click(); 
 }
 </script>


    <cfparam name="url.page" default="1">
<cfset page_links_shown = 5>
<cfset records_per_page = 10>

<cfset total_pages = ceiling(CQticketSearchResult.RecordCount / records_per_page)>

<cfif val(url.page) lt 1>
  <cfset url.page = 1>
<cfelseif val(url.page) gt total_pages>
  <cfset url.page = total_pages>
</cfif>
<cfset start_record = ((url.page - 1) * records_per_page ) + 1> 

  <CFIF isDefined("CQticketSearchResult") and #CQticketSearchResult.RecordCount# gt 0>
    <cfoutput query="CQticketSearchResult" startrow="#start_record#" maxrows="#records_per_page#"> 

Here goes the data


</cfioutput>
</cfif>

<cfoutput>
<hr>
<cfif url.page EQ 1>
   &laquo; Prev
<cfelse>
 <span onClick="PagingURL(#url.page-1#);" class="paggingRcd">&laquo; Prev</span>
</cfif>
&nbsp;|&nbsp;
<cfloop index="pp" from="1" to="#total_pages#">
  <cfif pp eq url.page>
   <strong>#pp#</strong> 
  <cfelse>
  <span onClick="PagingURL(#pp#);" class="paggingRcd">#pp#</span>
  </cfif>&nbsp;|&nbsp;
</cfloop>
<cfif url.page lt total_pages>
  <span onClick="PagingURL(#url.page+1#);" class="paggingRcd">Next &raquo; </span>
<cfelse>
  &laquo; Next
</cfif>
<hr>
</cfoutput>

Open in new window

0
Comment
Question by:lulu50
  • 2
3 Comments
 
LVL 39

Accepted Solution

by:
gdemaria earned 500 total points
ID: 41840990
Hi Lulu,
what do you want to show if the current page is say 50?
Perhaps something like this?
1 | 2 | ... | 49 | 50 | 51 |... | 999 | 1000

The big "CFELSEIF" statement here controls when the number shows and when a number is skipped..

<cfoutput>
<hr>
<cfif url.page EQ 1>
   &laquo; Prev
<cfelse>
 <span onClick="PagingURL(#url.page-1#);" class="paggingRcd">&laquo; Prev</span>
</cfif>
&nbsp;|&nbsp;
<cfset showedDots = false>
<cfloop index="pp" from="1" to="#total_pages#">
  <cfif pp eq url.page>
    <strong>#pp#</strong> 
	&nbsp;|&nbsp;
  <cfelseif pp lte 2 or pp gte val(total_pages)-1 or (pp gt val(url.page)-2 and pp lt val(url.page)+1)>
    <span onClick="PagingURL(#pp#);" class="paggingRcd">#pp#</span>
	<cfset showDots = false>
	&nbsp;|&nbsp;
  <cfelseif NOT showDots>
    <span class="paggingRcd">...</span>
	<cfset showDots = true>
	&nbsp;|&nbsp;
  <cfelse>
    <!--- <span onClick="PagingURL(#pp#);" class="paggingRcd">#pp#</span> --->
  </cfif>
</cfloop>
<cfif url.page lt total_pages>
  <span onClick="PagingURL(#url.page+1#);" class="paggingRcd">Next &raquo; </span>
<cfelse>
  &laquo; Next
</cfif>
<hr>
</cfoutput>

Open in new window

0
 

Author Comment

by:lulu50
ID: 41842351
gdemaria

I LOVE IT !!!!!!  

YOU ARE THE BEST OF THE BEST

THANK YOU SOOOOOOOOOOOO MUCHHHHHHHHHHHH

LULU
0
 

Author Closing Comment

by:lulu50
ID: 41842352
THANK YOU   THANK YOU AND ONE MORE THANK YOU  LOL
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now