jquery-pager分頁

來源:互聯網
上載者:User

標籤:style   blog   http   java   color   檔案   

首先引用這三個檔案

<script src="../../Scripts/jquery-1.4.4.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-pager-1.0.js" type="text/javascript"></script>
<link href="../../Scripts/pager.css" rel="stylesheet" type="text/css" />

 

HTML


<
body> <div> <div class="title"> <h1> 工作量統計表</h1> </div> <table width="50%" border="1" class="t1"> <thead> <th> 墓型代碼 </th> <th> 墓型名稱 </th> <th> 面積 </th> <th> 單價 </th> <th> 累計建墓 </th> </thead> <tbody style="text-align: center; font-size: 12px; color: black;"> </tbody> </table> <br /> <div id="page-bottom" style="width: 55%; border: 1px;" class="pageinfo"> </div> </div></body>

 

前端代碼:

<script language="javascript" type="text/javascript">        //得到頁面資料總數        function getPageCount() {            var result = "";            $.ajax({                type: "POST",                url: "/Manager/WorkStatistic/PageGetCount",                cache: "false",                async: false,                success: function (data) {                    result = eval(data);                },                error: function (XMLHttpRequest, textStatus, errorThrown) {                    alert("程式異常!");                }            });            return result;        };        $(document).ready(function () {            //載入頁數及頁碼            var recordCount = getPageCount();            InitPager(recordCount, 1);        });        function Init(PageIndex, PageCount) {            var receive_url = "/Manager/WorkStatistic/WorkStatistics?pageIndex=" + PageIndex + "&PageCount=" + PageCount;            $.ajax({                type: "GET",                url: receive_url,                cache: "false",                success: function (data) {                    data = eval(data);                    $("tbody").html("");                    var html = "";                    for (var i = 0; i < data.length; i++) {                        var json = data[i];                        var mxdm = json.mxdm;                        var mxdmmc = json.mxdmmc;                        var mj = json.mj;                        var dj = json.dj;                        var ljjm = json.ljjm;                        html += "<tr><td>" + mxdm + "</td><td>" + mxdmmc + "</td><td>" + mj + "</td><td>" + dj + "</td><td>" + ljjm + "</td></tr>";                    }                    $("tbody").append(html);                },                error: function (XMLHttpRequest, textStatus, errorThrown) {                    alert("程式異常!");                }            });        };        //RecordCount[總記錄數] PageIndex[當前頁碼]        function InitPager(RecordCount, PageIndex) {            $("#page-bottom").setPager({ RecordCount: RecordCount, PageIndex: PageIndex, buttonClick: PageClick });            //分頁同時更新資料來源            Init(PageIndex, 20);        };        //分頁事件        PageClick = function (RecordCount, PageIndex) {            InitPager(RecordCount, PageIndex);        };    </script>

 

用戶端代碼:

        public ActionResult WorkStatistics()        {            string pageIndex = Request.Params.Get("PageIndex");            string pageCount = Request.Params.Get("PageCount");            int page = Convert.ToInt32(pageIndex) * Convert.ToInt32(pageCount);            string SQL_Init = @"SELECT * FROM ( SELECT rownum RN,t.* FROM ( SELECT a.mxdm,a.mxdmmc,a.mj,AVG((SELECT dj FROM mxdm WHERE a.mxdm= mxdm)) dj,COUNT(*) ljjm"                + " FROM mwdmxx a WHERE a.azfsdm= ‘01‘ GROUP BY a.mxdm ,a.mxdmmc,a.mj ORDER BY a.mxdm) t WHERE  rownum <=" + page + ") WHERE RN > " + (page - Convert.ToInt32(pageCount));            DataSet ds = DBhelper.Query(SQL_Init);            //執行個體化結構體數組            TombType_SaleInfo[] result = new TombType_SaleInfo[ds.Tables[0].Rows.Count];            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)            {                string mxdm = ds.Tables[0].Rows[i]["MXDM"].ToString();                string mxdmmc = ds.Tables[0].Rows[i]["MXDMMC"].ToString();                double mj = Double.Parse(ds.Tables[0].Rows[i]["MJ"].ToString() == "" ? "0" : ds.Tables[0].Rows[i]["MJ"].ToString());                int dj = Int32.Parse(ds.Tables[0].Rows[i]["DJ"].ToString() == "" ? "0" : ds.Tables[0].Rows[i]["DJ"].ToString());                int ljjm = Int32.Parse(ds.Tables[0].Rows[i]["LJJM"].ToString() == "" ? "0" : ds.Tables[0].Rows[i]["LJJM"].ToString());                TombType_SaleInfo temp = new TombType_SaleInfo(mxdm, mxdmmc, mj, dj, ljjm);                result[i] = temp;            }            return Json(result, JsonRequestBehavior.AllowGet);        }        //得到資料總條數        public void PageGetCount()        {            string SQL_Init = @"SELECT count(*) FROM (SELECT count(a.mxdm)  FROM mwdmxx a WHERE a.azfsdm= ‘01‘ GROUP BY a.mxdm ,a.mxdmmc,a.mj )";            string count = DBhelper.GetScalar(SQL_Init);            Response.Write(count);            Response.End();        }

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.