码迷,mamicode.com
首页 > Web开发 > 详细

jquery pagination.js 分页

时间:2015-02-03 12:43:18      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:

js代码:

var pageIndex = 0;     //页面索引初始值  
            var pageSize = 10;     //每页显示条数初始化,修改显示条数,修改这里即可  
            var where="";          //查询条件
            var searchwhere="";    //查询条件
            
            function PageSet(data){
                 //分页,PageCount是总条目数,这是必选参数,其它参数都是可选  
                $("#Pagination").pagination(data , {  
                    callback: PageCallback,  
                    prev_text: ‘上一页‘,       //上一页按钮里text  
                    next_text: ‘下一页‘,       //下一页按钮里text  
                    items_per_page: pageSize,  //显示条数  
                    num_display_entries: 6,    //连续分页主体部分分页条目数  
                    current_page: pageIndex,   //当前页索引  
                    num_edge_entries: 2        //两侧首尾分页条目数  
                });  
            }
            
            $(function() {                                               
                $.get("../AjaxHandler/GetPageCount.ashx",{pwhere:searchwhere,strWhere:where,tb:3},function(data){                                      
                      PageSet(data);
                });
                 
            });
            
            $("#strWhere").bind("change",function(){
                    var type1=$("#strWhere option:selected").val();
                    alert(type1);
                    //var where1="";
                    switch(type1){
                        case "全部":
                            where="";
                            break;
                        case "返修登记":
                             where="返修登记";
                             break;
                        case "到货确认":
                             where="返修登记,到货确认";
                             break;
                        case "维修开始":
                             where="返修登记,到货确认,维修开始";
                             break;
                        case "维修完成":
                             where="返修登记,到货确认,维修开始,维修完成";
                             break;
                         case "设备交付":
                              where="返修登记,到货确认,维修开始,维修完成,设备交付";
                              break;
                    }
                    $("#emptable tbody tr").remove(); //移除Id为Result的表格里的行,从第二行开始(这里根据页面布局不同页变)             
                    $.get("../AjaxHandler/GetPageCount.ashx",{pwhere:searchwhere,strWhere:where,tb:3,t:"6,8,10,11"},function(data){                                      
                          PageSet(data);
                    });
                    //InitTable(pageIndex);  
                 });
                 $("#search").bind("click",function(){
                      searchwhere=$("#searchvalue").val();
                      $("#emptable tbody tr").remove();
                      $.get("../AjaxHandler/GetPageCount.ashx",{pwhere:searchwhere,strWhere:where,tb:3,t:"6,8,10,11"},function(data){                                      
                           PageSet(data);
                      });
                      //InitTable(pageIndex);
                 });   
                //翻页调用  
                function PageCallback(index, jq) {  
                    $("#emptable tbody tr").remove(); //移除Id为Result的表格里的行,从第二行开始(这里根据页面布局不同页变)             
                    InitTable(index);  
                }  
                //请求数据  
                function InitTable(pageIndex) {  
                    var twhere=where;
                    var pwhere=searchwhere;                           
                    $.ajax({   
                        type: "POST",  
                        dataType: "json",  
                        url: ‘../AjaxHandler/RepairSelect.ashx‘,      //提交到一般处理程序请求数据  
                        data: "pageIndex=" + (pageIndex + 1) +"&&strWhere="+twhere+"&&pwhere="+pwhere,    //提交一个参数:pageIndex(页面索引)  
                        success: function(data) {                                   
                           var html="";
                           var loginUser=$("#loginUser").val();
                           $.each(data,function(k,v){
                              var arrays=v.Status.split(‘,‘);
                              if(loginUser=="sysadmin"){
                                 html+="<tr class=‘gradeX odd‘><td><input class=‘checkboxes‘ value="+v.ID+" type=‘checkbox‘/></td><td><a href=‘#responsive2‘ data-toggle=‘modal‘ onclick=‘lookdetail("+v.ReportNum+")‘ alt=‘查看详细‘>"+v.ReportNum+"</a></td><td ><a href=‘#responsive3‘ data-toggle=‘modal‘ onclick=‘looksnu(this)‘ alt=‘查看详细‘>"+v.SNumber+"</a></td><td name="+v.Status+">"+arrays[arrays.length-1]+"</td><td >"+v.CompanyName+"</td><td >"+v.Reporter+"</td><td><a href=‘#responsive2‘ data-toggle=‘modal‘ onclick=‘lookdetail("+v.DeliveryNum+")‘ alt=‘查看详细‘>"+v.DeliveryNum+"</a></td><td><a href=‘javascript:;‘ onclick=‘lookstatus(this)‘ class=‘btn mini blue‘><i class=‘icon-reload‘></i> 查看</a></td><td ><div style=‘width:100px; white-space:nowrap;overflow:hidden;text-overflow:ellipsis;‘ title="+v.Reason+">"+v.Reason+"</div></td><td style=‘width:190px;margin:0; padding:8px 0;‘><a href=‘#responsive0‘ id=‘checkin‘ scr="+v.ID+" data-toggle=‘modal‘ class=‘btn mini blue‘ onclick=‘check(this);‘><i class=‘icon-edit‘></i>登记</a>&nbsp;|&nbsp;<a href=‘#responsive1‘ id=‘checkin‘ scr="+v.ID+" data-toggle=‘modal‘ class=‘btn mini blue‘ onclick=‘updateq(this);‘><i class=‘icon-edit‘></i>编辑</a>&nbsp;|&nbsp;<a href=‘javascript:;‘ onclick=‘del("+v.ID+")‘ class=‘btn mini black‘><i class=‘icon-trash‘></i> 删除</a></td></tr>";
                              }else{
                                 html+="<tr class=‘gradeX odd‘><td><input class=‘checkboxes‘ value="+v.ID+" type=‘checkbox‘/></td><td><a href=‘#responsive2‘ data-toggle=‘modal‘ onclick=‘lookdetail("+v.ReportNum+")‘ alt=‘查看详细‘>"+v.ReportNum+"</a></td><td ><a href=‘#responsive3‘ data-toggle=‘modal‘ onclick=‘looksnu(this)‘ alt=‘查看详细‘>"+v.SNumber+"</a></td><td name="+v.Status+">"+arrays[arrays.length-1]+"</td><td >"+v.CompanyName+"</td><td >"+v.Reporter+"</td><td><a href=‘#responsive2‘ data-toggle=‘modal‘ onclick=‘lookdetail("+v.DeliveryNum+")‘ alt=‘查看详细‘>"+v.DeliveryNum+"</a></td><td><a href=‘javascript:;‘ onclick=‘lookstatus(this)‘ class=‘btn mini blue‘><i class=‘icon-reload‘></i> 查看</a></td><td ><div style=‘width:100px; white-space:nowrap;overflow:hidden;text-overflow:ellipsis;‘ title="+v.Reason+">"+v.Reason+"</div></td><td style=‘width:130px;margin:0; padding:8px 0;‘><a href=‘#responsive0‘ id=‘checkin‘ scr="+v.ID+" data-toggle=‘modal‘ class=‘btn mini blue‘ onclick=‘check(this);‘><i class=‘icon-edit‘></i>登记</a>&nbsp;|&nbsp;<a href=‘#responsive1‘ id=‘checkin‘ scr="+v.ID+" data-toggle=‘modal‘ class=‘btn mini blue‘ onclick=‘updateq(this);‘><i class=‘icon-edit‘></i>编辑</a></td></tr>";
                              }
                           });
                           $("#emptable tbody").append(html);             //将返回的数据追加到表格  
                        }  
                    });              
                } 

 

jquery pagination.js 分页

标签:

原文地址:http://www.cnblogs.com/anyben/p/4269620.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!