1.封装MODEL

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MODEL.FormatModel
{
public class TableModel<T>
{
public T rows { get; set; }
public int total{get;set;}

}
}

2.方法

public ActionResult GetContentList()
{
int currentPage = HttpContext.Request.Params["offset"] == null ? 1 : int.Parse(HttpContext.Request.Params["limit"]);
// 每页行数
int showCount = HttpContext.Request.Params["limit"] == null ? 10 : int.Parse(HttpContext.Request.Params["limit"]);
if (currentPage != 0)
{// 获取页数
currentPage = currentPage / showCount;
}
currentPage += 1;

List<MODEL.Content> allModelList = OperateContext.Current.BLLSession.IContentBLL.Get(c => 1 == 1).ToList().OrderByDescending(c => c.PostDate).ToList();
int rows = allModelList.Count / showCount;
int total = allModelList.Count;
List<MODEL.Content> modelList = allModelList.Take(showCount * currentPage).Skip(showCount * (currentPage - 1)).ToList();

List<MODEL.Content> contentList = new List<MODEL.Content>();
MODEL.Content content = null;
for (int i = 0; i < modelList.Count; i++)
{
content = modelList[i].ToPo();
if (!string.IsNullOrWhiteSpace(content.Catalog))
{

string cId = content.Catalog;
MODEL.Catalog catalogModel = OperateContext.Current.BLLSession.ICataLogBLL.Get(c => c.ID == cId).FirstOrDefault();
if (catalogModel != null)
{
content.Catalog = catalogModel.Name;
}
else
{
content.Catalog = "";
}
}
else
{
content.Catalog = "";
}
contentList.Add(content);

}
//System.Text.StringBuilder sb = new StringBuilder();
//System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer();

//jss.Serialize(contentList, sb);
//string contentListJsonStr = "\"rows\":\"" + sb.ToString() + "\",\"total\":\"" + total + "\"";
MODEL.FormatModel.TableModel<List<MODEL.Content>> tableModel = new MODEL.FormatModel.TableModel<List<MODEL.Content>>();
tableModel.rows = contentList;
tableModel.total = total;
return Json(tableModel, JsonRequestBehavior.AllowGet);
}

3.前端

<table data-toggle="table" id="table" data-toolbar="#toolbar" data-url="/Admin/Site/GetContentList" data-show-refresh="true" data-show-toggle="true" data-show-columns="true" data-search="true" data-pagination="true" data-side-pagination="server" data-page-list="[5, 10, 20, 50, 100, 200]" data-sort-name="name" data-sort-order="desc">
<thead>
<tr>
<th data-field="state" data-checkbox="true" class="col-sm-1"></th>
<th data-field="ID" data-visible="false">ID</th>
<th data-field="Title" data-sortable="true" class="col-sm-3">标题</th>
<th data-field="Abbreviations" data-sortable="true" class="col-sm-3">缩略语</th>
<th data-field="Catalog" data-sortable="true" class="col-sm-1">栏目</th>
<th data-field="IsPublish" data-sortable="true" class="col-sm-1">是否发布</th>
<th data-field="Poster" data-sortable="true" class="col-sm-1">发布人</th>
<th data-field="PostDate" data-sortable="true" class="col-sm-1">发布时间</th>
<th data-field="Operation" data-formatter="actionFormatter" data-events="actionEvents" class="col-sm-1">操作</th>
</tr>
</thead>
</table>

bootstrap table 服务器分页的更多相关文章

  1. [前端插件]Bootstrap Table服务器分页与在线编辑应用总结

    先看Bootstrap Table应用效果: 表格用来显示数据库中的数据,数据通过AJAX从服务器加载,同时分页功能有服务器实现,避免客户端分页,在加载大量数据时造成的用户体验不好.还可以设置查询数据 ...

  2. bootstrap table 服务器端分页例子分享

    这篇文章主要介绍了bootstrap table 服务器端分页例子分享,需要的朋友可以参考下 1,前台引入所需的js 可以从官网上下载 复制代码代码如下: function getTab(){var ...

  3. 161222、Bootstrap table 服务器端分页示例

    bootstrap版本 为 3.X bootstrap-table.min.css bootstrap-table-zh-CN.min.js bootstrap-table.min.js 前端boot ...

  4. [转]Bootstrap table后端分页(ssm版)

    原文地址:https://www.cnblogs.com/flyins/p/6752285.html 说明bootstrap table可以前端分页,也可以后端sql用limit分页.这里讲的是后端分 ...

  5. Bootstrap table后端分页(ssm版)

    说明bootstrap table可以前端分页,也可以后端sql用limit分页.这里讲的是后端分页,即实用limit.性能较好,一般均用这种源码下载地址:https://git.oschina.ne ...

  6. Bootstrap table前端分页(ssm版)

    说明bootstrap table可以前端分页,也可以后端sql用limit分页.前端分页下性能和意义都不大,故一般情况下不用这种,请看我的另一篇后端分页的博客源码下载地址:https://git.o ...

  7. C# Bootstrap table之 分页

    效果如图: 一.声明talbe <div class="container"> <table id="table" class="t ...

  8. [转]C# Bootstrap table之 分页

    本文转自:https://www.cnblogs.com/zhangjd/p/7895453.html 效果如图: 一.声明talbe <div class="container&qu ...

  9. bootstrap table 服务器端分页--ashx+ajax

    1.准备静态页面 1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta http-equiv="Content-T ...

随机推荐

  1. 深入理解计算机系统第二版习题解答CSAPP 2.3

    填写空白.单字节可以用两个十六进制数表示. 十进制 二进制 十六进制 0 0000 0000 0x00 167 1010 0111 0xA7 62 0011 1110 0x3E 188 1011 11 ...

  2. 制作win7+ubuntu +winPE+CDlinux多系统启动U盘

    制作前期准备工作 1.需要软件 grub4dos(http://sourceforge.net/projects/grub4dos/files/) UltraISO(http://cn.ezbsyst ...

  3. BFM1

    BFM应该描述的是具有某种具体功能的电路.比如说,你的待测电路是一个智能卡,那他的BFM就是读卡器:那你就要根据协议,在BFM中描述出读卡器的具体行为. 写BFM就类似于写testbench了.BFM ...

  4. mysql自增

    主键设置自增,同时主键需要是int类型

  5. NChome导出补丁包需要注意的东西

  6. JSON 与List转换类封装

    json与list转换小结: import java.util.ArrayList; import java.util.List; import com.google.gson.Gson; impor ...

  7. Dev ComboxTree的实现

    一个项目中刚好用到,自己做下笔记备份 顺便和大家共享下 需要用到ASPxDropDownEdit ASPxTreeView 这两个控件 ASPxDropDownEdit对应的dll为:DevExpre ...

  8. 在html页,使用ctrl,shift多选表格行

    前段时间,项目中遇到这样一个需求.需要在页面中像windows资源管理器中一样可以使用ctrl和shift键来多选. <html> <head> <style> b ...

  9. Jstl标签库/Filter过滤器

    JSTLJSP Standard Tag Library JSP标准标签库 是Sun公司定义的一套标准,由Apache组织基于这套标准开发的一套标准库之后又转给Sun公司被称为JSTL,成为了java ...

  10. MD5/SHA加密

    public class EncryptUtil { public static String getEncrypt(String value , String encrypt_type){ Stri ...