bootstrap table 服务器分页
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 服务器分页的更多相关文章
- [前端插件]Bootstrap Table服务器分页与在线编辑应用总结
先看Bootstrap Table应用效果: 表格用来显示数据库中的数据,数据通过AJAX从服务器加载,同时分页功能有服务器实现,避免客户端分页,在加载大量数据时造成的用户体验不好.还可以设置查询数据 ...
- bootstrap table 服务器端分页例子分享
这篇文章主要介绍了bootstrap table 服务器端分页例子分享,需要的朋友可以参考下 1,前台引入所需的js 可以从官网上下载 复制代码代码如下: function getTab(){var ...
- 161222、Bootstrap table 服务器端分页示例
bootstrap版本 为 3.X bootstrap-table.min.css bootstrap-table-zh-CN.min.js bootstrap-table.min.js 前端boot ...
- [转]Bootstrap table后端分页(ssm版)
原文地址:https://www.cnblogs.com/flyins/p/6752285.html 说明bootstrap table可以前端分页,也可以后端sql用limit分页.这里讲的是后端分 ...
- Bootstrap table后端分页(ssm版)
说明bootstrap table可以前端分页,也可以后端sql用limit分页.这里讲的是后端分页,即实用limit.性能较好,一般均用这种源码下载地址:https://git.oschina.ne ...
- Bootstrap table前端分页(ssm版)
说明bootstrap table可以前端分页,也可以后端sql用limit分页.前端分页下性能和意义都不大,故一般情况下不用这种,请看我的另一篇后端分页的博客源码下载地址:https://git.o ...
- C# Bootstrap table之 分页
效果如图: 一.声明talbe <div class="container"> <table id="table" class="t ...
- [转]C# Bootstrap table之 分页
本文转自:https://www.cnblogs.com/zhangjd/p/7895453.html 效果如图: 一.声明talbe <div class="container&qu ...
- bootstrap table 服务器端分页--ashx+ajax
1.准备静态页面 1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta http-equiv="Content-T ...
随机推荐
- Java基础知识强化之IO流笔记56:IO流练习之 登录注册IO版
1. 登录注册IO版的Java项目框架,如下: 2. 具体代码实现: (1)User.java(cn.itcast.game): package cn.itcast.pojo; /** * 这是用户 ...
- Android(java)学习笔记139:在TextView组件中利用Html插入文字或图片
首先我们看看代码: 1.activity_main.xml: <LinearLayout xmlns:android="http://schemas.android.com/apk/r ...
- html5标签兼容ie6,7,8
注册博客园已经三年了,这三年一直在忙,没时间写博文.也许是忙,也许是懒吧!当然这三年发生了很多事,我也从开发人员转变为前端人员. 是时候对所学的,所用的知识做一下沉淀了.就从这一篇开始吧! html5 ...
- Spring-data-redis操作redis cluster
Redis 3.X版本引入了集群的新特性,为了保证所开发系统的高可用性项目组决定引用Redis的集群特性.对于Redis数据访问的支持,目前主要有二种方式:一.以直接调用jedis来实现:二.使用sp ...
- react中的坑
9. 渲染界面的时候让滚动条回到顶部 //渲染界面的时候让滚动条回到顶部 componentDidMount() { window.scrollTo(0,0); } 路由: <Route pat ...
- Es6 之箭头函数 初学
不积跬步,无以至千里;不积小流,无以成江海! // ES5 var selected = allJobs.filter(function (job) { return job.isSelected() ...
- StringBuffer跟StringBuilder以及HashMap跟HashTable
StringBuffer是线程安全的 HashTable是线程安全的,但HashMao单线程程序中的性能比HashTable要高,对了HashTable用(add),HashMap用的(put)
- 将Excel,ppt和word转化为html
有些时候可能需要将Excel,ppt和word转化为html在页面上显示.我从网上查到一些代码,记录在这里以供需要的朋友参考 1.将word转化为html显示 //================== ...
- /etc/resolv.conf文件详解
大家好,今天51开源给大家介绍一个在配置文件,那就是/etc/resolv.conf.很多网友对此文件的用处不太了解.其实并不复杂,它是DNS客户机配置文件,用于设置DNS服务器的IP地址及DNS域名 ...
- mybatis()
---------------------------------mysql分页---------------------------------- public void selectList(in ...