所以最好是修改jquerydatatable控件,给生成的每个datatable下的checkbox赋 予不同的id,因为datatable的id是不一样的,所以可以把 datatable的id作为 checkbox的前缀组成一个唯一的id 。 具体这个checkbox的调用事件也需要同步 替换成这个新id,进行事件的调用。
[修改文件]
jqureydatatableextjs (v001) MVC项目中有的时候List的条数比较多,需要分页显示,可以用如下的办法:
1、写一个简单PaginatedList 辅助类:
public class PaginatedList<T> : List<T> {
public int PageIndex { get; private set; }
public int PageSize { get; private set; }
public int TotalCount { get; private set; }
public int TotalPages { get; private set; }
public PaginatedList(IQueryable<T> source, int pageIndex, int pageSize) {
PageIndex = pageIndex;
PageSize = pageSize;
TotalCount = sourceCount();
TotalPages = (int) MathCeiling(TotalCount / (double)PageSize);
thisAddRange(sourceSkip(PageIndex PageSize)Take(PageSize));
}
public bool HasPreviousPage {
get {
return (PageIndex > 0);
}
}
public bool HasNextPage {
get {
return (PageIndex+1 < TotalPages);
}
}
}
2、Controller中使用这个PaginatedList 类来返回View:
public ActionResult Index(int page) {
const int pageSize = 10;
var upcomingDinners = dinnerRepositoryFindUpcomingDinners();
var paginatedDinners = new PaginatedList<Dinner>(upcomingDinners, page 0,pageSize);
return View(paginatedDinners);
}
3、View中实现导航链接的Code如下:
<% if (ModelHasPreviousPage) { %>
<%= HtmlRouteLink("<<<", "UpcomingDinners", new { page =
(ModelPageIndex-1) }) %>
<% } %>
<% if (ModelHasNextPage) { %>
<%= HtmlRouteLink(">>>", "UpcomingDinners", new { page = (ModelPageIndex +
1) }) %>
<% } %>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)