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. 查看MySQL数据库表的命令介绍

    如果需要查看MySQL数据库中都有哪些MySQL数据库表,应该如何实现呢?下面就为您介绍查看MySQL数据库表的命令,供您参考. 进入MySQL Command line client下查看当前使用的 ...

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

    给出位微量的布尔去处的求值结果. 运算 结果 a 0110 1001 b 0101 0101     ~a 1001 0110 ~b 1010 1010     a&b 0100 0001 a ...

  3. verilog中的task用法

    任务就是一段封装在“task-endtask”之间的程序.任务是通过调用来执行的,而且只有在调用时才执行,如果定义了任务,但是在整个过程中都没有调用它,那么这个任务是不会执行的.调用某个任务时可能需要 ...

  4. 【转】Android 应用测试总结

    前提所有的功能分支已完成 启动:1. 启动入口:桌面正常启动,最近运行启动,所有程序列表中启动,锁屏快捷启动2. 其他入口:从其他程序开启应用,从外部以文件形式打开应用(如果有)3. 退回:从其他程序 ...

  5. 【S】【S】【S】一大波前端干货整合(一)

      前端交流站点 大前端       http://www.daqianduan.com/ V2EX       http://www.v2ex.com/ W3cplus    http://www. ...

  6. xml_02

    1.xml 2.对于XML文档的约束   |-DTD      <!DOCTYPE 根元素 [       <!ELEMENT 元素名 (xx)>       <!ATTLIS ...

  7. ElastciSearch常用APi

    列出所有的索引: GET /_cat/indices?v 删除索引 DELETE /customer?pretty

  8. 那天有个小孩跟我说LINQ(七)转载

    1  LINQ TO XML(代码下载)        准备:新建项目 linq_Ch7控制台程序,新建一个XML文件夹,我们就轻松地学习一下吧          XDocument         ...

  9. swift-07-使用for-in 遍历数组

    //for-in /* for 迭代变量 in集合变量 { 使用迭代变量便利所有数据 } */ //遍历数组 var arr = ["a" ,"b" ,&quo ...

  10. struts2 I18n问题 国际化

    java国际化 1.了解缺省Locale是由操作系统决定的,Locale是由语言和国家代码组成 2.国际化资源文件是由baseName+locale组成,如:MessageBundle_en_US.p ...