Solved

paging

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

Stressed Out?

Watch some penguins on the livecam!

Question has a verified solution.

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

PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

688 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