?
Solved

paging

Posted on 2016-10-12
3
Medium Priority
?
63 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 39

Accepted Solution

by:
gdemaria earned 2000 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

Quick Cloud Training

Looking for some quick training on the cloud in 2 hours or less? Check out these how-to guides in AWS, Linux, OpenStack, Azure, and more!

Question has a verified solution.

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

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

764 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