- Url路由分页
- Ajax分页
- Ajax搜索分页
- 外观样式
- 分页数据相关
- Javascrip API
- AjaxPager 类
- AjaxHelper.Pager 扩展方法
- HtmlPager 类
- HtmlHelper.Pager 扩展方法
- IPagedList 接口
- IPagedList<T> 接口
- MvcAjaxOptions 类
- MvcAjaxOptionsBuilder 类
- PagedList<T> 类
- PageLinqExtensions 类
-
PagerOptions 类
- ActionName属性
- AlwaysShowFirstLastPageNumber属性
- AutoHide属性
- ContainerTagName属性
- ControllerName属性
- CssClass属性
- CurrentPageNumberFormatString属性
- CurrentPagerItemTemplate属性
- DisabledPagerItemTemplate属性
- FirstPageRouteName属性
- FirstPageText属性
- GoToButtonId属性
- HidePagerItems属性
- HorizontalAlign属性
- HtmlAttributes属性
- Id属性
- InvalidPageIndexErrorMessage属性
- LastPageText属性
- MaximumPageIndexItems属性
- MaximumPageNumber属性
- MorePagerItemTemplate属性
- MorePageText属性
- NavigationPagerItemsPosition属性
- NavigationPagerItemTemplate属性
- NextPageText属性
- NumericPagerItemCount属性
- NumericPagerItemTemplate属性
- OnPageIndexError属性
- PageIndexBoxId属性
- PageIndexOutOfRangeErrorMessage属性
- PageIndexParameterName属性
- PageNumberFormatString属性
- PagerItemTemplate属性
- PrevPageText属性
- RouteName属性
- RouteValues属性
- ShowDisabledPagerItems属性
- ShowFirstLast属性
- ShowMorePagerItems属性
- ShowNumericPagerItems属性
- ShowPrevNext属性
- PagerItemsPosition 枚举
- PagerOptionsBuilder 类
- ScriptResourceExtensions 类
- Javascript API
- AjaxPager.cs
- AjaxPagerTest.cs
- DataLoaderBuilder.cs
- DisplayNameExtensions.cs
- HtmlPager.cs
- HtmlPagerTest.cs
- IPagedList.cs
- MvcAjaxOptions.cs
- MvcAjaxOptionsBuilder.cs
- MvcPager.js
- PagedList.cs
- PagedListTest.cs
- PageLinqExtensions.cs
- PagerBuilder.cs
- PagerExtensions.cs
- PagerItem.cs
- PagerItemsPosition.cs
- PagerOptions.cs
- PagerOptionsBuilder.cs
- ScriptResourceExtensions.cs
- TestHelper.cs
MvcPager 源代码 — pagelinqextensions.cs
/* MvcPager source code
This file is part of MvcPager.
Copyright 2009-2015 Webdiyer(http://en.webdiyer.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
using System.Collections.Generic;
using System.Linq;
namespace Webdiyer.WebControls.Mvc
{
///<include file='MvcPagerDocs.xml' path='MvcPagerDocs/Classes/Class[@name="PageLinqExtensions"]/*'/>
public static class PageLinqExtensions
{
///<include file='MvcPagerDocs.xml' path='MvcPagerDocs/PageLinqExtensions/Method[@name="ToPagedList1"]/*'/>
public static PagedList<T> ToPagedList<T>
(
this IQueryable<T> allItems,
int pageIndex,
int pageSize
)
{
if (pageIndex < 1)
pageIndex = 1;
var itemIndex = (pageIndex-1) * pageSize;
var totalItemCount = allItems.Count();
while (totalItemCount <= itemIndex&&pageIndex>1)
{
itemIndex = (--pageIndex - 1) * pageSize;
}
var pageOfItems = allItems.Skip(itemIndex).Take(pageSize);
return new PagedList<T>(pageOfItems, pageIndex, pageSize, totalItemCount);
}
///<include file='MvcPagerDocs.xml' path='MvcPagerDocs/PageLinqExtensions/Method[@name="ToPagedList2"]/*'/>
public static PagedList<T> ToPagedList<T>(this IEnumerable<T> allItems, int pageIndex, int pageSize)
{
return allItems.AsQueryable().ToPagedList(pageIndex, pageSize);
}
}
}