Solved

paging

Posted on 2016-10-12
3
28 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

746 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

11 Experts available now in Live!

Get 1:1 Help Now