• jquery 分页


    最近有点无所事事,无聊之极!

    啊啊啊,表示很痛苦!

                    <div id="tablist_01" class="list_tab">
    		  <table width="765" border="0" cellspacing="0" cellpadding="0" class="list04">
              </table>
    		  <div class="pages"><a href="javascript:void(0);" onclick="pre(event);"><<上一页</a><a href="javascript:void(0);" onclick="nxt(event);">下一页>></a></div>
    		  </div>
    

      

              function investmentGrid(page) {
                    var investmentUrl = "/tradeRecord/getTradeRecordList";
                    var investment = ajax(investmentUrl,{customer_id:customerid, page:page}, false);
                    var total = investment.total;
                    var rows = investment.rows;
                    var tab = $("#tablist_01 table");
                    $.each(rows, function(index, row) {
            var html = '<tr>';
            if(page == 1){
                html += '<td>' + (index+1) + '</td>';
            }else{
                html += '<td>' + ((index+1)+((page-1)*10)) + '</td>';
            }
            tab.append(html);
            });
                // 分页
        $("#tablist_01 .pages").html('<a href="javascript:void(0);" onclick="pre(event);">&lt;&lt;上一页</a><a href="javascript:void(0);" onclick="nxt(event);">下一页&gt;&gt;</a>');
        var footer = getFooter(total, page, "investmentGrid");
        $("#tablist_01 .pages").find("a:first").after(footer);
                  
              }

    分页

              function getFooter(total, page, callback, pageSize) {
        var footer = '';
        pageSize = pageSize ? pageSize : 10;
        for (var i = 0; i < total / pageSize; i++) {
            var p = i + 1;
            if (p == 1 || p == parseInt(total / pageSize)) {
            } else if (page - p > 4) {
                continue;
            } else if (page - p == 4) {
                footer += "...";
                continue;
            } else if (p - page == 6) {
                footer += "...";
                continue;
            } else if (p - page > 6) {
                continue;
            }
            footer += (p == page ? "<b>" + p + "</b>" : '<a href="javascript:void(0);" onclick="jump(' + p + ', ' + callback + ')">' + p + '</a>');
        }
        return footer;
    }
    
    
              function pre(event) {//上一页
        event = event ? event : window.event; 
        var obj = event.srcElement ? event.srcElement : event.target;
        var $p = $(obj).parent().find("b");
        if ($p.length > 0) {
            var page = $p.html();
            if (page == 1) {
                alert("已经是第一页!");
            } else {
                $p.prev("a").trigger("click");
            }
        }
    }
    
    function nxt(event) {//下一页
        event = event ? event : window.event; 
        var obj = event.srcElement ? event.srcElement : event.target;
        var $p = $(obj).parent().find("b");
        if ($p.length > 0) {
            if ($p.next("a")[0] == $(obj)[0]) {
                alert("已经是最后一页!");
            } else {
                $p.next("a").trigger("click");
            }
        }
    }
    
    
    function jump(page, callback) {
        callback(page);
    }

    Java,后台代码查询:

     public Map<String,Object> getList(AccountStreamVoBean accStrVo){
        Map<String, Object> map = new HashMap<String, Object>();
        List<Map<String, Object>> list = this.cusAccDao.getAccStream(accStrVo);//查询数据
        int count = cusAccDao.getAccStreamCount(accStrVo);//查询共有多少条数
        map.put("rows", list);
        map.put("total", count);
        return map;
     }

    没心情!

    时间,请带我像一条小溪流般,安静地流淌,汇入爱的海洋。
  • 相关阅读:
    安全购买数码相机的诀窍!(1)
    获得网卡MAC地址和IP地址
    用Asp.net实现基于XML的留言簿之二
    安全购买数码相机的诀窍!(2)
    使用Flash读取COOKIE
    数码常识:CCD的原理
    ACE 5.5 Make in RedHat AS 4 Update 4 Issue
    Eclipse Plugins 开发 (1)
    RedHat AS4 Update4 DNS (bind 9) 配置
    Maven2 & Continuum 持续整合 (1)
  • 原文地址:https://www.cnblogs.com/1246447850qqcom/p/4250610.html
Copyright © 2020-2023  润新知