首页 > Web开发 > 详细

Ajax分页(MVC下)(附源码,前后台)

时间:2015-11-02 16:55:37      阅读:272      评论:0      收藏:0      [点我收藏+]

网上找的一个分页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

使用上有问题请@我

Ajax分页(MVC下)(附源码,前后台)

原文:http://www.cnblogs.com/gaocong/p/4930258.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!