Java web js perfectly paginated, with only one div

Source: Internet
Author: User

Java web js perfectly paginated, with only one div

Java web js perfect paging front and back end should be combined! Original package

Js

 

/** Pagination ** // initfunction pageFn (_ url, _ param) {// init sendReq (_ url, _ param ); // homepage // $ ("# _ firstPage "). click (function () {// var param = getParam (); // param. mPageIndex = 1; // sendReq (_ url, param); //}); // last page // $ ("# _ lastPage "). click (function () {// var param = getParam (); // var lastPageVar = $ ("# _ sizePage" ).html (); // param. mPageIndex = parseInt (lastPageVar, 10); // sendReq (_ url, param); //}); // Previous Page // $ ("# _ pageUp "). cl Ick (function () {// var param = getParam (); // var currentPageVar = $ ("# _ currentPage" ).html (); // param. mPageIndex = parseInt (currentPageVar, 10)-1; // sendReq (_ url, param );////}); // next page // $ ("# _ nextPage "). click (function () {// var param = getParam (); // the current page // var currentPageVar =$ ("# _ currentPage" ).html (); // param. mPageIndex = parseInt (currentPageVar, 10) + 1; // sendReq (_ url, param );////}); // jump // $ ("# _ jumpPage "). Click (function () {// var jumpPageVar = $ ("# jumpPageText "). val (); // if (checkStr (jumpPageVar) // {// alert ("enter a valid number when you jump to the page! "); // Return; //} // var param = getParam (); // param. mPageIndex = jumpPageVar; // sendReq (_ url, param); //}); // click function clickNumFn (I, url) {var param = getParam (); param. mPageIndex = I; sendReq (url, param);} function pagecClickEnv (url, P) {var param = getParam (); // var currentPageVar =$ ("# _ currentPage" ).html (); if (P = "N") {param. mPageIndex = parseInt (currentPageVar, 10) + 1;} else if (P = "U") {param. mPageIndex = par SeInt (currentPageVar, 10)-1;} else if (P = "L") {var lastPageVar = $ ("# _ sizePage" pai.html (); param. mPageIndex = parseInt (lastPageVar, 10);} else if (P = "T") {param. mPageIndex = 1;} else if (P = "J") {var jumpPageVar = $ ("# jumpPageText "). val (); if (checkStr (jumpPageVar) {alert ("enter a valid number to jump to the page! "); Return;} var param = getParam (); param. mPageIndex = jumpPageVar;} sendReq (url, param);}/*** send request ***/function sendReq (_ url, obj) {$. post (_ url, obj, function (returnDatas, status) {if (status = "success") {var jsonData = JSON. stringify (returnDatas); eval ('callbak _ page ('+ jsonData +'); // pagination information var pageinfoHTML = "Total
 
  
"+ ReturnDatas. mRecords +"
 Article No. "+ returnDatas. mCurrentPage + "/
 
  
"+ ReturnDatas. mPages +"
 Page "; // $ (" # _ pageInfos ").html (pageinfoHTML); // var paginationNum ="
"+ PageinfoHTML +" Homepage "; paginationNum + =" <"; for (var I = returnDatas. startNo; I <(returnDatas. startNo + returnDatas. showNum); I ++) {if (returnDatas. mPages

 

 

/***** Pagination ****/. pagination {padding: 20px 0; width: 888px; margin: 0 auto; color: # adadad; font-size: 14px; font-family: "";}. pagination ,. pagination span {padding: 6px 10px; color: # adadad; display: inline-block; margin-left: 3px; background: # fff ;}. pagination. pageSelected ,. pagination. current {background: # 468FCB; color: # fff; text-decoration: none; cursor: pointer ;}. pagination. pageFl {color: # DCDCDC! Important; background: # fff! Important;}. pagination span,. pagination a {vertical-align: middle}. pagination a {font-family: Arial;}. pagination span {font-weight: bold ;}


 

 

<script src="${pagecontext.request.contextpath}/audit/js/util/page.js" type="text/javascript"></script>
 

 

 

Background

 

package com.youboy.crm.dto.pager;public class Query {private int mPageIndex;private int mPageSize = 20;private boolean needPage = true;public Query() {super();}public Query(int mPageIndex, int mPageSize) {this.mPageIndex = mPageIndex;this.mPageSize = mPageSize;}public int getmPageIndex() {return mPageIndex > 0 ? mPageIndex : 1;}public void setmPageIndex(int mPageIndex) {this.mPageIndex = mPageIndex;}public int getmPageSize() {return mPageSize > 0 ? mPageSize : 0;}public void setmPageSize(int mPageSize) {this.mPageSize = mPageSize;}public int getmStartRow() {if (mPageIndex <= 0) {return 0;}return (mPageIndex - 1) * mPageSize;}public boolean isNeedPage() {return needPage;}public void setNeedPage(boolean needPage) {this.needPage = needPage;}@Overridepublic String toString() {return "Query [mPageIndex=" + mPageIndex + ", mPageSize=" + mPageSize+ ", needPage=" + needPage + "]";}}
Package com. youboy. crm. dto. pager; import java. util. List; public class QueryResult
  
   
{Private int mPages; // total number of pages private long mRecords; // total number of records private List
   
    
MItems; private int mCurrentPage = 1; // private int startNo on the current page; // start number private int showNum = 10; // Number of display numbers public int getmPages () {return mPages;} public void setmPages (int mPages) {this. mPages = mPages;} // calculate the total number of pages public void setmPages (long mRecords, long mpageSize) {this. mRecords = mRecords; if (mRecords <= 0) {this. mPages = 1; return;} if (mRecords <= mpageSize) {this. mPages = 1; return;} long totalPages = mR Ecords/mpageSize; this. mPages + = (totalPages + (mRecords % mpageSize = 0? 0: 1);} public long getmRecords () {return mRecords;} public void setmRecords (long mRecords) {this. mRecords = mRecords;} public List
    
     
GetmItems () {return mItems;} public void setmItems (List
     
      
MItems) {this. mItems = mItems;} public int getmCurrentPage () {if (mCurrentPage <= 0) {mCurrentPage = 1;} if (this. getmPages () <mCurrentPage) // if the current page is greater than the data page {mCurrentPage = this. getmPages ();} return mCurrentPage;} public void setmCurrentPage (int mCurrentPage) {this. mCurrentPage = mCurrentPage;} public int getStartNo () {if (startNo <= 0) {return 1;} return startNo;} public static int getStartNo2 (int pages, int showNum, int cIndex) {// Calculate if (pages <cIndex) {// System based on the current page. out. println ("cget" + getmPages (); cIndex = pages;} else if (cIndex <= 0) {// cIndex = 1 ;} if (cIndex % showNum = 0) {// number of lines displayed on the current page // System. out. println (cIndex-showNum + 1); return cIndex-showNum + 1;} else {// if the current page is smaller than the starting line if (cIndex <showNum) {return 1 ;} else {// the remainder of the current page (current surface and number of displayed rows) return cIndex-(cIndex % showNum) + 1 ;}} public void setStartNo (int startNo) {this. startNo = startNo; // System. out. println ("cIndex:" + cIndex); // System. out. println (showNum); // System. out. println (startNo); // start line of the root queue "current page % number displayed = whether to flip the page/if (getmCurrentPage () % showNum = 1) {// if (getmPages () <= startNo) {// this. startNo = getmPages ()-showNum; //} else {// this. startNo = getmCurrentPage (); // + 1; //} else if (getmCurrentPage () % showNum = 0) {/this. startNo = getmCurrentPage ()-showNum; //} else {// this. startNo = startNo; //} // if (startNo <= 0 | this. startNo <= 0) {// this. startNo = 1; //} public int getShowNum () {return showNum;} public void setShowNum (int showNum) {this. showNum = showNum ;}@ Overridepublic String toString () {return "QueryResult [mPages =" + mPages + ", mRecords =" + mRecords + ", mItems =" + mItems + ", mCurrentPage = "+ mCurrentPage +", startNo = "+ startNo +", showNum = "+ showNum +"] ";} public static void main (String [] args) {int s = 5; int index = 19; System. out. println (index % s); if (index % s = 0) {// The number of lines displayed on the current page: System. out. println (index-s + 1);} else {// if the current page is smaller than the starting line if (index <s) {System. out. println (1);} else {// current page-remainder (current surface and number of displayed rows) System. out. println ("f:" + (index % s) + 1 ));}}}}
     
    
   
  



 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.