zoukankan      html  css  js  c++  java
  • Ajax分页(MVC下)(附源码,前后台)

    网上找的一个分页js,自己改了改。。

    前台页面

    @{
        ViewBag.Title = "Index";
    }
    <h1>分页方法封装</h1>
    <script src="~/gc-ui/js/gc-js/gc-js/jq_print/jquery-1.4.4.min.js"></script>
    <script src="~/gc-ui/Pager/js/ajax_hack_gc.js"></script>
    <script src="~/gc-ui/Pager/js/jquery.simplePagination.js" charset="gbk"></script>
    <script src="~/gc-ui/Pager/js/gc_pager.js"></script>
    <link href="~/gc-ui/Pager/css/simplePagination.css" rel="stylesheet" />
    <script>
        $(function () {
            //$("#gc")
            var arr = [];
            arr.push("id");
            $.yms_Pager_ajax("gc", "/home/data", arr);
        });
    </script>
    <center>
        <table id="gc">
            <thead>
                <tr>
                    <td>序号</td>
                    <td>姓名</td>
                </tr>
            </thead>
            <tbody></tbody>
        </table>
    </center>

    后台控制器代码(用的ef)

     public ActionResult Index()
            {
                return View();
            }
            public ActionResult Data(int pageIndex = 1, int pageSize = 3)
            {
                testEntities t = new testEntities();
                List<ddd> list = t.ddd.ToList();
                
    
                int zys/*总页数*/ = (list.Count + pageSize - 1) / pageSize;
                var show_data/*json数据*/ = new { data = list.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList(), count = zys };
                return Json(show_data, JsonRequestBehavior.AllowGet);
            }
    

     js文件我上传上来。。

    http://files.cnblogs.com/files/gaocong/Pager.rar

    使用上有问题请@我

  • 相关阅读:
    动态规划小练
    组合计数小练
    【WC2019】 通道
    【PKUSC2018】主斗地
    【NOI2009】诗人小G
    【THUWC 2017】随机二分图
    【NOI2017】游戏与2-sat方案输出
    Codeforces 1109D sasha and interesting fact from graph theory
    Codeforces 1152E neko and flashback
    ZJOI2019游记
  • 原文地址:https://www.cnblogs.com/gaocong/p/4930258.html
Copyright © 2011-2022 走看看