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. 关于android应用--内存的优化

    以下内容为转载自网上,然后自己加工贴合到一块的: 原文地址:http://www.cnblogs.com/frydsh/archive/2012/12/09/2810601.html http://w ...

  2. leecode 每日解题思路 64 Minimum Path Sum

    题目描述: 题目链接:64 Minimum Path Sum 问题是要求在一个全为正整数的 m X n 的矩阵中, 取一条从左上为起点, 走到右下为重点的路径, (前进方向只能向左或者向右),求一条所 ...

  3. 加快modelsim仿真速度的方法(原创)

    ①仿真精度越高,仿真效率月底. 仿真时采用`timescale 1ns/1ns比采用1ns/100ps的仿真效率高 simulation was two billion ns. ②clock gene ...

  4. 移动端 touch 实现 拖动元素

    var homeMove = (function () { //touch自适应 var k = "ontouchend" in window ? "touchend&q ...

  5. 安卓项目-利用Sqlite数据库,开发新闻发布系统

    本教程致力于程序员可以快速的学习安卓移动端手机开发. 适合于已经习得一种编程语言的同仁. 更多志同道合,想要学习更多编程技术的大神们. 小弟不才,麻烦关注一下我的今日头条号-做全栈攻城狮. 本文章是基 ...

  6. ASP.NET 设计模式(转)

    Professional ASP.NET Design Patterns 为什么学习设计模式? 运用到ASP.NET应用程序中的设计模式.原则和最佳实践.设计模式和原则支持松散耦合.高内聚的代码,而这 ...

  7. OC - 6.block与protocol

    一.block 1> 基本使用 相当于用来存放代码的代码块 效率高 若没有形参可以省略小括号 2> block与函数的相同点 可以保存代码 可以有返回值 可以有形参 调用方式一样 3> ...

  8. Prism for WPF 第一讲 Event机制

    在本篇文章中主要讲解在Prism中模块与模块之间事件关联的机制.在这里牵涉到三个名词:事件定义,事件发布,事件订阅. 第一:事件定义 在公共类库中定义事件. ①没有参数事件 public class ...

  9. 01_JavaMail_02_Base64加密

    [简述] Base64是网络上最常见的用于传输8Bit字节代码的编码方式之一.Base64编码可用于在HTTP环境下传递较长的标识信息.例如,在Java Persistence系统Hibernate中 ...

  10. [USACO1.1.4]坏掉的项链Broken Necklace

    P1203 [USACO1.1]坏掉的项链Broken Necklace 标签 搜索/枚举 USACO 难度 普及- 题目描述 你有一条由N个红色的,白色的,或蓝色的珠子组成的项链(3<=N&l ...