真分页

Posted zhangsonglin

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了真分页相关的知识,希望对你有一定的参考价值。

var sign = "";
            var custid;
            var f_uid;
            var pagecount;///总页数
            var rawcount;///记录总数
            var cust_name = ""
            //var nickname = "";
            var mobil = "";
            var pageIndex = 1;
            var pageSize = 6;//设定每页条数
            var abc = [];
            var cde = [];
            //点击弹窗的清空按钮
            function clearinput() {
                $("#unameSearch").val("");

                $("#mobilSearch").val("");
            };
            function cleaninput() {
                $("#uname").val("");

                $("#mobil").val("");
            };
            function AjaxGetData(cust_name, mobil, index, size) {
                $.ajax({
                    url: "bookstrapSelect.ashx",
                    type: "post",
                    data: {
                        "cust_name": cust_name,
                        "Mobil": mobil,
                        "Group" : "",
                        "PageIndex": index,
                        "PageSize": size
                    },
                    dataType: "json",
                    success: function (data) {
                        if (data.Count > 0) {
                            past_name = cust_name;
                           
                            past_mobil = mobil;
                            rawcount = data.Count;
                            if (rawcount > 0) {
                                var htmlstr = "";
                                if (index == 1 && $("#LinkmanA").val() !== "" && $("#mobilSearch").val() == "" && $("#unameSearch").val() == "") {
                                    htmlstr += "<tr role=‘row‘ id=‘firstLine‘style=‘background-color: #2fafcc‘>" +
                                    "<td style=‘display: none;‘>" + ‘‘ + "</td>" +
                                    "<td>" + abc[0] + "</td>" +
                                       "<td>" + abc[1] + "</td>" +
                               "</tr>"
                                    $("#RelationA").html(htmlstr)
                                }
                                pagecount = rawcount % pageSize == 0 ? parseInt(rawcount / pageSize) : parseInt(rawcount / pageSize + 1);
                                for (var i = 0; i < data.LinkMan.length; i++) {
                                    htmlstr += "<tr role=‘row‘ class=‘odd‘data-dismiss=‘modal‘>" +
                                ‘<td style="display: none;">‘ + data.LinkMan[i].cust_id + ‘</td>‘ +
                                ‘<td name=‘ + data.LinkMan[i].cust_id + ‘ >‘ + data.LinkMan[i].cust_name+ ‘</td>‘ +
                                 ‘<td >‘ + (data.LinkMan[i].Mobil == null ? "" : data.LinkMan[i].Mobil) + ‘</td>‘ +
                                //‘<td>‘ + data.LinkMan[i].Mobil == null ? "" : data.LinkMan[i].Mobil + ‘</td>‘+
                                "</tr>";
                                    $("#RelationA").html(htmlstr)
                                }
                                var html = "<div class=‘col-xs-12‘ id=‘test‘>" + "</div>";
                                //"<button class=‘btn btn-sm btn-info pull-right‘ id=chose data-dismiss=‘modal‘style=‘margin-right:40px;‘>" +
                                //"选择" +
                                //"</button>"
                                $("#chase").html(html);
                                //分页
                                $("#test").page({ count: rawcount, pageNo: pageIndex, pageSize: pageSize, showNum: 5, btnName: "跳转" });
                                ///跳转
                                $("#test .pagination_search").click(function () {
                                    var jumppage = $("#test .pagination_change_page").val();
                                    if (jumppage == "") {
                                        alert("跳转页码不能为空");
                                    } else if (jumppage <= 0 || jumppage > pagecount)
                                        alert("跳转页码不能超出范围");
                                    else {
                                        pageIndex = parseInt($(document).find("#test .pagination_change_page").val());
                                        AjaxGetData(past_name, past_mobil, pageIndex, pageSize);
                                    }
                                });
                                ///点击
                                $("#test .pagination li").click(function () {
                                    pageIndex = $(this).attr("num");
                                    if ($(this).attr("class") == "disabled") {
                                        return false;
                                    }
                                    if (pageIndex == 0 || pageIndex == (pagecount + 1)) {

                                    } else {
                                        AjaxGetData(past_name, past_mobil, pageIndex, pageSize);
                                    }
                                });
                                //点击改变背景颜色
                                $(".odd").click(function () {
                                    $(this).addClass("selected").siblings().removeClass("selected");//添加当前,移除兄弟节点
                                    var custId = $(" tr.selected").children().eq(0).text();
                                    var Name = $(" tr.selected").children().eq(1).text();
                                    var mobile = $(" tr.selected").children().eq(2).text();
                                    $("#LinkmanA").val(Name)
                                    $("#LinkmanA").attr("value", custId)
                                    $("#LinkmanA").attr("name", mobile)
                                });
                            }
                        }
                        else {
                            $("#RelationA").html("<tr><td class=‘center‘ colspan=‘4‘>没有该联系人相关资料</td></tr>");
                        }
                    }
                })
            }

            //初始化
            $(function () {
                autosize($(‘textarea[class*=autosize]‘));

                //点击弹窗的查询按钮
                var past_name = "";///名字
                //var past_nickname = "";///昵称
                var past_mobil = "";///电话
                $("#btnSearch").click(function () {
                    var name = $("#unameSearch").val();
                    var mobil = $("#mobilSearch").val();
                    pageIndex = 1;
                    AjaxGetData(name, mobil, pageIndex, pageSize);
                });
                $("#btnSearch").click();
                //$("#Search").click(function () {
                //    var Name = $("#uname").val();
                //    var Mobil = $("#mobil").val();
                //    pageIndex = 1;
                //    AjaxGetDataB(Name, Mobil, pageIndex, pageSize);
                //});
                //$("#Search").click();

                $("#LinkmanA").click(function () {
                    $("#unameSearch").val("");
                    $("#mobilSearch").val("");
                    var inputName = $("#LinkmanA").val();
                    var inputMobile = $("#LinkmanA").attr("name");
                    console.log(inputName);
                    if (inputName == "") { $("#firstLine").addClass("firstLine") }
                    else {
                        abc = [inputName, inputMobile]
                        pageIndex = 1;
                        AjaxGetData(name, mobil, pageIndex, pageSize);
                        $("#firstLine").removeClass("firstLine");
                    }
                });
            

                //解析url中参数
                function getUrlParam(name) {
                    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
                    var r = window.location.search.substr(1).match(reg);  //匹配目标参数
                    if (r != null) return unescape(r[2]); return null; //返回参数值

                }
                //uid = getUrlParam(‘cust_id‘);
                //f_uid = getUrlParam(‘F_UID‘);
                //var aname = decodeURI(getUrlParam(‘A_UName‘));
                //var bname = decodeURI(getUrlParam(‘B_UName‘));
                //var relaid = getUrlParam(‘RelaID‘);
                //var intiid = getUrlParam(‘IntiID‘);
                //var memo = decodeURI(getUrlParam(‘Memo‘));
                //$.ajax({
                //    url: "../AddRelation/GetInfo",
                //    type: "Get",
                //    dataType: "json",
                //    success: function (data) {
                //        var html = ‘<option value="" disabled selected hidden>  </option>‘
                //        //$("#linkmanA").append(htmlstr);
                //        //$("#linkmanB").append(htmlstr);
                //        $("#Rela").append(html);
                //        $("#Intimacy").append(html);
                //        if (uid != null) {
                //            $("#LinkmanA").attr("value", uid)
                //            $("#LinkmanA").val(aname)
                //            $("#LinkmanA").parent().removeAttr("href")
                //            if (f_uid != null) {
                //                $("#LinkmanB").parent().removeAttr("href")
                //                $("#LinkmanB").attr("value", f_uid)
                //                $("#LinkmanB").val(bname)
                //            }
                //        }
                //        for (var i = 0; i < data.RelationType.length; i++) {
                //            if (data.RelationType[i].Type == ‘1‘) {
                //                html = ‘<option ‘;
                //                if (data.RelationType[i].Code_id == relaid)
                //                    html += ‘selected = "selected" ‘;
                //                html += ‘value = "‘ + data.RelationType[i].Code_id + ‘" > ‘ + data.RelationType[i].Relaname + ‘</option > ‘;
                //                $("#Rela").append(html);
                //            }
                //            else {
                //                html = ‘<option ‘
                //                if (data.RelationType[i].Code_id == intiid)
                //                    html += ‘selected = "selected" ‘;
                //                html += ‘value = "‘ + data.RelationType[i].Code_id + ‘" > ‘ + data.RelationType[i].Relaname + ‘</option > ‘;
                //                $("#Intimacy").append(html);
                //            }
                //        };
                //        if (memo != ‘null‘)
                //            $("#Memo").val(memo);
                //        if (uid != null && f_uid != null) {
                //            $("#linkmanA").attr("disabled", true);
                //            $("#linkmanA").css("background-color", "#EEEEEE");
                //            $("#linkmanB").attr("disabled", true);
                //            $("#linkmanB").css("background-color", "#EEEEEE");
                //            $("#btn_search").css(‘display‘, ‘none‘);
                //            $("#del_btn").css(‘display‘, ‘‘);
                //        }
                //    },
                //    error: function (XMLHttpRequest, textStatus, errorThrown) {
                //        alert(XMLHttpRequest);
                //        alert(textStatus);
                //        alert(errorThrown);
                //    }
                //});

            });
            ///查询关系
            //function searchrel() {
            //    var linkmanA = $("#LinkmanA").attr("value");
            //    //var linkmanB = $("#LinkmanB").attr("value");
            //    if (linkmanA == "" || linkmanA == null) {
            //        alert("联系人A名字为空,请重新选择"); return;
            //    }
            //    //if (linkmanB == "" || linkmanB == null) {
            //    //    alert("联系人B名字为空,请重新选择"); return;
            //    //}
            //    $.ajax({
            //        url: "../AddRelation/searchrel",
            //        type: "POST",
            //        data: "UID=" + linkmanA + "&F_UID=" + linkmanB,
            //        dataType: "json",
            //        success: function (data) {
            //            if (data.Count > 0)
            //                alert("关系:" + data.Relation_Extra[0].Relaname + " 亲密度:" + data.Relation_Extra[0].Intiname);
            //            else
            //                alert(‘两者没有直接关系‘);
            //        },
            //        error: function (XMLHttpRequest, textStatus, errorThrown) {
            //            alert(XMLHttpRequest);
            //            alert(textStatus);
            //            alert(errorThrown);
            //        }
            //    });
            //}

            //有效性检验
            function checkForm() {
                var linkmanA = $("#LinkmanA").val();
               // var linkmanB = $("#LinkmanB").val();
               


                if (linkmanA == "" || linkmanA == null) {
                    alert("联系人A名字为空,请重新选择"); return false;
                }

以上是关于真分页的主要内容,如果未能解决你的问题,请参考以下文章

单页分页问题中的多个角度材料表

梦内容页分页标题提取

一个视图中的 CI 多页分页,

以多页分页打印所有数据

CakePHP 2中带有分页分页类的大小为f数组的问题

当我在基于类的视图中应用过滤器时,如何在 django 中使用分页分页。网址总是不断变化我如何跟踪网址