jquery paging display control kkpager uses

Keywords: Javascript JSON JQuery Java

This demo will explain two ways:
1: link mode (setting a tag link address with different parameters: < a href = "xxxx. html? Current = 3"> 3 </a>; current: current: current page number)
Second: click mode (custom function jump, ajax mode, by clicking the event to send ajax requests to obtain data. ajax paging)
===================================================================================

Preparations, introducing js and css
<script type="text/javascript" src="../lib/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="../src/kkpager.min.js"></script>
<link rel="stylesheet" type="text/css" href="../src/kkpager.css" />

HTML DOM
<div id="kkpager"></div> 

Backstage Java Code, simulated query data base

Backstage use struts2 and json, not to mention much!

One: link mode

    <script type="text/javascript">  
            var sum = '${sum}';//Total Data Bar Background Return Data  
              var totalPage = Math.ceil(sum/3);//Total Page Number Total Data Bars/Display Number per Page Up  
            var current = '${current}';//Current Page Background Returns Data  
            if(current == 0){  
                current = 1;  
            }  
            $(function(){  
                //Initialization function  
                kkpager.generPageHtml({  
                pno : current, //page  
                total : totalPage,//PageCount  
                totalRecords : sum, //Total number of data bars  
                mode:'link', //Default to link mode  
                getLink : function(n){  
                    return 'usercontent/user.do?current='+n; //Setting the href address n of label a to represent the page number  
                },  
                 //Optional, with default values   
                lang : {  
                    firstPageText : 'First page',  
                    lastPageText : 'last page',  
                    prePageText : 'Previous page',  
                    nextPageText : 'next page',  
                    totalPageBeforeText : 'common',  
                    totalPageAfterText : 'page',  
                    totalRecordsAfterText : 'Bar data',  
                    gopageBeforeText : 'go to',  
                    gopageButtonOkText : 'Determine',  
                    gopageAfterText : 'page',  
                    buttonTipBeforeText : 'The first',  
                    buttonTipAfterText : 'page'  
                }  
            });  
    });  
    </script>  

2: click mode (ajax partial refresh)

    $(function(){  
            var sum = '${sum}';//Total Data Bar Background Return Data  
            var totalPage = Math.ceil(sum/3);//Total Page Number Total Data Bars/Display Number per Page Up  
            var current = '${current}';//Current Page Background Returns Data  
            if(current == 0){  
                    current = 1;  
            }  
            //Initialization function  
            kkpager.generPageHtml({  
                    pno : current, //page  
                    total : totalPage,//PageCount  
                    totalRecords : sum, //Total number of data bars  
                    mode:'click', //This is set to click mode  
                    lang : {  
                            firstPageText : 'First page',  
                            lastPageText : 'last page',  
                            prePageText : 'Previous page',  
                            nextPageText : 'next page',  
                            totalPageBeforeText : 'common',  
                            totalPageAfterText : 'page',  
                            totalRecordsAfterText : 'Bar data',  
                            gopageBeforeText : 'go to',  
                            gopageButtonOkText : 'Determine',  
                            gopageAfterText : 'page',  
                            buttonTipBeforeText : 'The first',  
                            buttonTipAfterText : 'page'  
                },  
                //Click on the function of the page number to send an ajax request to the background  
                click:function(n){  
                        $(".data-d table").html("");  
                        html = "<tr><td>id</td><td>uname</td><td>age</td><td>upwd</td></tr>";  
                        $.post("usercontent/ajax.do?current="+n,function(data){  
                        $.each(data,function(i,obj){  
                                html +="<tr><td>"+obj.id+"</td><td>"+obj.uname+"</td><td>"+obj.age+"</td><td>"+obj.upwd+"</td></tr>";  
                        })  
                        $(".data-d table").html(html);  
                },"json")  
                this.selectPage(n); //Select Page for Page Selection Switching with Manual Bar  
               },  
                //Set href link address by default#  
                getHref:function(n){  
                        return "javascript:;;";  
                }  
        });  
    });  

Parametric configuration instructions:

Required parameters

pno Current Page Number

Total total page number

Total Records

Optional parameters

Paging Display Control Container ID String Default Value'kkpager'

mode, click or link string default value'link'

Is isShow Total Page Display Total Page Boolean Default Value true

Is Show Total Records Displaying Total Records Boolean Default Value true

Is isShowFirstPageBtn Display Home Button Boolean Default Value true

Is isShowLastPageBtn Display the Back Page Button Boolean Default Value true

Does isShowPrePageBtn Display the Boolean Default Value of the Last Page Button

Is isShowNextPageBtn Display Next Page Button Boolean Default Value true

Is isGoPage Displaying Page Jump Input Box Boolean Default Value true

hrefFormer Link Front String Default Value''

hrefLatter Link Tail String Default Value''

Language Configuration Object, Attribute Configuration List (configurable only here in lang:{xxx}):

  • First PageText Home Button Text String Default'Home Page'

  • First PageTipText Home button prompt text string default value'Home Page'

  • Last Page Text End Page Button Text String Default Value'End Page'

  • Last PageTipText End Page button prompts text string default value'End Page'

  • prePageText Previous button text string Default value'Previous page'

  • prePageTipText Previous page button prompt text string default value'Previous page'

  • Next Page Text Next Page Button Text String Default'Next Page'

  • Next Page TipText Next Page Tip Button Text String Default'Next Page'

  • Total Page BeforeText Total Page Prefix Text String Default Value'Total'

  • Total Page AfterText Total Page Suffix Text String Default Value'Page'

  • Total Records AfterText Total Records Text String Default Value'Bar Data'

  • Gopage BeforeText jumps prefix text string default value'to'

  • gopageAfterText Jump Prefix Text String Default Value'Page'

  • Gopage Button OkText jump button text string default value'OK'

  • Button Tip BeforeText Page Number Button Tip Information Prefix String Default Value'

  • buttonTipAfterText Page Number Button Tip Information Suffix String Default Value'Page'

gopageWrapId Page Number Jump dom ID String Default value'kkpager_gopage_wrap'

gopageButtonId Page Number Jump button dom ID string default value'kkpager_btn_go'

GopageTextbox Id Page Number Input Box dom ID String Default Value'kkpager_btn_go_input'

getLink algorithm Function (only applicable to mode l as link) function type

Click Custom Event Handler (only applicable to click with mode) function type

getHref Link Algorithmic Function (only applicable to click mode) function type

Posted by sleepingdanny on Wed, 17 Apr 2019 09:39:32 -0700