/// <summary> /// 基于AjaxHelper的分页扩展方法 /// </summary> /// <param name="ajax">AjaxHelper</param> /// <param name="totalItemCount">总记录数</param> /// <param name="pageSize">每页显示条数</param> /// <param name="pageIndex">当前页</param> /// <param name="actionName">Action</param> /// <param name="controllerName">Controller</param> /// <param name="routeName">路由名称</param> /// <param name="pagerOptions">分页参数</param> /// <param name="routeValues">路由值</param> /// <param name="ajaxOptions">Ajax参数</param> /// <param name="htmlAttributes">Html参数</param> /// <returns>MvcHtmlString</returns> public static MvcHtmlString Pager(this AjaxHelper ajax, long totalItemCount, int pageSize, int pageIndex, string actionName, string controllerName, string routeName, PagerOptions pagerOptions, RouteValueDictionary routeValues, AjaxOptions ajaxOptions, IDictionary <string, object> htmlAttributes) { var totalPageCount = (int)Math.Ceiling(totalItemCount / (double)pageSize); var builder = new PagerBuilder(ajax, actionName, controllerName, totalPageCount, pageIndex, pagerOptions, routeName, routeValues, ajaxOptions, htmlAttributes); return(builder.RenderPager()); }
/// <summary> /// Ajax分页扩展方法 /// </summary> /// <param name="html">HtmlHelper</param> /// <param name="totalItemCount">总记录数</param> /// <param name="pageSize">每页显示条数</param> /// <param name="pageIndex">当前页</param> /// <param name="actionName">Action</param> /// <param name="controllerName">Controller</param> /// <param name="routeName">路由名称</param> /// <param name="pagerOptions">分页参数</param> /// <param name="routeValues">路由值</param> /// <param name="ajaxOptions">Ajax参数</param> /// <param name="htmlAttributes">Html参数</param> /// <returns>MvcHtmlString</returns> public static MvcHtmlString AjaxPager(this HtmlHelper html, long totalItemCount, int pageSize, int pageIndex, string actionName, string controllerName, string routeName, PagerOptions pagerOptions, RouteValueDictionary routeValues, AjaxOptions ajaxOptions, IDictionary <string, object> htmlAttributes) { if (pagerOptions == null) { pagerOptions = new PagerOptions(); } pagerOptions.UseJqueryAjax = true; var totalPageCount = (int)Math.Ceiling(totalItemCount / (double)pageSize); var builder = new PagerBuilder(html, actionName, controllerName, totalPageCount, pageIndex, pagerOptions, routeName, routeValues, ajaxOptions, htmlAttributes); return(builder.RenderPager()); }
/// <summary> /// 分页扩展方法 /// </summary> /// <param name="helper">HtmlHelper</param> /// <param name="totalItemCount">总记录数</param> /// <param name="pageSize">每页显示记录数</param> /// <param name="pageIndex">当前页</param> /// <param name="actionName">Action</param> /// <param name="controllerName">Controller</param> /// <param name="pagerOptions">分页参数</param> /// <param name="routeName">路由名称</param> /// <param name="routeValues">路由值</param> /// <param name="htmlAttributes">HtmlAttributes</param> /// <returns>MvcHtmlString</returns> public static MvcHtmlString Pager(this HtmlHelper helper, long totalItemCount, int pageSize, int pageIndex, string actionName, string controllerName, PagerOptions pagerOptions, string routeName, object routeValues, object htmlAttributes) { var totalPageCount = (int)Math.Ceiling(totalItemCount / (double)pageSize); var builder = new PagerBuilder ( helper, actionName, controllerName, totalPageCount, pageIndex, pagerOptions, routeName, new RouteValueDictionary(routeValues), new RouteValueDictionary(htmlAttributes) ); return(builder.RenderPager()); }