[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

paging

Posted on 2016-10-12
3
Medium Priority
?
72 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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…
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

649 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