• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

ASP.NET MVC 4+ T.JPager使用

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

一、同步Link模式

 

                   var pagecount = TCalcPager.CalcPageCount(count, pageSize);
                    var page = new TBuilderLinkPager()
                    {
                        Tag = "a",
                        PageCount = pagecount,
                        PageSize = pageSize,
                        PageIndex = pageIndex,
                        Path = "/home/list/",
                        CurrentPageClassName = "page_curr",
                        NextPageName = ">",
                        UpPageName = "<"
                    };
                    page.Params.Add(UserId);
                    page.BuilderHTML();
                    //将页码,总页数和查询的当前页的集合传递到视图上
                    ViewBag.PagerHTML = page.PagerHTML;
                    ViewBag.PageIndex = pageIndex;
                    ViewBag.PageCount = pagecount;

/Home/List/UserId/PageIndex

备注: PageIndex会默认附加到最后一个参数

二、异步事件模式

                  var pagecount = TCalcPager.CalcPageCount(count, pageSize);
                    var page = new TBuilderPager
                    {
                        Tag = "a",
                        PageCount = pagecount,
                        PageSize = pageSize,
                        PageIndex = pageindex,
                        Path = "/Search/List",
                        NextPageClickName = "nextPager",
                        UpPageClickName = "upPager",
                        CurrentPageClassName = "page_curr",
                        PageClickName = "pager",
                        NextPageName = "下一页",
                        UpPageName = "上一页"
                    };
             
                    page.BuilderHTML();
                    //将页码,总页数和查询的当前页的集合传递到视图上
                    ViewBag.PagerHTML = page.PagerHTML;
                    ViewBag.PageIndex = pageindex;
                    ViewBag.PageCount = pagecount;

 

1.单个视图页的js,事件命名必须是 pager(href, pageindex){}

 

//通用分页click
function pager(href, pageindex) {
    var _begintime = $("#g_begintime_hidden").val();
    var _endtime = $("#g_endtime_hidden").val();
    var _tiaojian = $("#g_tiaojian_hidden").val();
    g_loading();
    $("#gonghuolist").load(href, { pageindex: pageindex, beginTime: _begintime, endTime: _endtime, tiaojian: _tiaojian, state: $("#shenhezhuangtai_hidden").val() }, function () {
        g_closeloading();
    });
}

 三、JPager MVC扩展类

  public static class TJPagerExtentions
    {
        /// <summary>
        /// 异步标准版
        /// </summary>
        /// <param name="help"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        public static IHtmlString Pager(this HtmlHelper help, TBuilderPager param)
        {
            var page = new TBuilderPager
            {
                Tag = param.Tag,
                PageCount = param.PageCount,
                PageSize = param.PageSize,
                PageIndex = param.PageIndex,
                Path = param.Path,
                NextPageClickName = param.NextPageClickName,
                UpPageClickName = param.UpPageClickName,
                CurrentPageClassName = param.CurrentPageClassName,
                PageClickName = param.PageClickName,
                NextPageName = param.NextPageName,
                DefaultClassName = param.DefaultClassName,
                UpPageName = param.UpPageName,
                HomePageClassName = param.HomePageClassName,
                LastPageClassName = param.LastPageClassName
            };
            page.BuilderHTML();
            return help.Raw(page.PagerHTML);
        }

        /// <summary>
        /// 异步带首页尾页版
        /// </summary>
        /// <param name="help"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        public static IHtmlString PagerWithFL(this HtmlHelper help, TBuilderPager param)
        {
            var page = new TBuilderPager
            {
                Tag = param.Tag,
                PageCount = param.PageCount,
                PageSize = param.PageSize,
                PageIndex = param.PageIndex,
                Path = param.Path,
                NextPageClickName = param.NextPageClickName,
                UpPageClickName = param.UpPageClickName,
                CurrentPageClassName = param.CurrentPageClassName,
                PageClickName = param.PageClickName,
                NextPageName = param.NextPageName,
                UpPageName = param.UpPageName,
                DefaultClassName = param.DefaultClassName,
                HomeAndLastPageClickName = param.HomeAndLastPageClickName,
                HomePageClassName = param.HomePageClassName,
                LastPageClassName = param.LastPageClassName
            };
            page.BuilderHTMLWithFL();
            return help.Raw(page.PagerHTML);
        }

        /// <summary>
        /// 异步极小的,不带总页数+首页尾页的版
        /// </summary>
        /// <param name="help"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        public static IHtmlString PagerWithNormal(this HtmlHelper help, TBuilderPager param)
        {
            var page = new TBuilderPager
            {
                Tag = param.Tag,
                PageCount = param.PageCount,
                PageSize = param.PageSize,
                PageIndex = param.PageIndex,
                Path = param.Path,
                NextPageClickName = param.NextPageClickName,
                UpPageClickName = param.UpPageClickName,
                CurrentPageClassName = param.CurrentPageClassName,
                PageClickName = param.PageClickName,
                NextPageName = param.NextPageName,
                UpPageName = param.UpPageName,
                DefaultClassName = param.DefaultClassName,

            };
            page.BuilderHTMLWithBuilderWithNormal();
            return help.Raw(page.PagerHTML);
        }


        /// <summary>
        /// 同步标准版
        /// </summary>
        /// <param name="help"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        public static IHtmlString LinkPage(this HtmlHelper help, TBuilderLinkPager param)
        {
            var page = new TBuilderLinkPager
            {
                Tag = param.Tag,
                PageCount = param.PageCount,
                PageSize = param.PageSize,
                PageIndex = param.PageIndex,
                Path = param.Path,
                CurrentPageClassName = param.CurrentPageClassName,
                NextPageName = param.NextPageName,
                UpPageName = param.UpPageName,
                DefaultClassName = param.DefaultClassName,
                HomePageClassName = param.HomePageClassName,
                LastPageClassName = param.LastPageClassName
            };
            page.BuilderHTML();
            return help.Raw(page.PagerHTML);
        }


        /// <summary>
        /// 同步带首页尾页版本
        /// </summary>
        /// <param name="help"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        public static IHtmlString LinkPageWithFL(this HtmlHelper help, TBuilderLinkPager param)
        {
            var page = new TBuilderLinkPager
            {
                Tag = param.Tag,
                PageCount = param.PageCount,
                PageSize = param.PageSize,
                PageIndex = param.PageIndex,
                Path = param.Path,
                CurrentPageClassName = param.CurrentPageClassName,
                NextPageName = param.NextPageName,
                UpPageName = param.UpPageName,
                DefaultClassName = param.DefaultClassName,
                HomePageClassName = param.HomePageClassName,
                LastPageClassName = param.LastPageClassName

            };
            page.BuilderHTMLWithFL();
            return help.Raw(page.PagerHTML);
        }
    }

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Asp.net修改Xml文档中的数据发布时间:2022-07-10
下一篇:
asp.net服务器控件调用javascript发布时间:2022-07-10
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap