bootstrap表格分页
<script src="~/Scripts/jquery.min.js"></script>
<script src="~/Scripts/bootstrap.min.js"></script>
<script src="~/Scripts/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="~/Scripts/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<div class="panel-body" style="padding-bottom:0px;">
<div class="tableWrap">
<div class="cxbottom"><button type="submit" class="cxbtn" onclick="Search();">查 询</button></div>
<table width="100%" border="0">
<tr>
<th width="12%">活动日期:</th>
<td width="21%">
<div class="" id="data_5">
<div class="input-daterange input-group" id="datepicker">
<input type="text" class="input-sm form-control" name="start" value="2014-11-11" />
<span class="input-group-addon">到</span>
<input type="text" class="input-sm form-control" name="end" value="2014-11-17" />
</div>
</div> </td>
<th width="12%">活动名称:</th>
<td width="21%">
<input type="text" placeholder="" class="form-control" style="border-radius:3px; height:30px" id="activeName">
</td>
<th width="12%">是否推荐:</th>
<td width="22%"><input type="checkbox" class="js-switch" checked /></td>
</tr>
<tr>
<th>活动名称:</th>
<td><input type="text" placeholder="" class="form-control" style="border-radius:3px; height:30px"></td>
<th>是否上线:</th>
<td><input type="text" placeholder="" class="form-control" style="border-radius:3px; height:30px" id="online"></td> </tr>
</table>
</div> <div id="toolbar" class="btn-group">
<button id="btn_add" type="button" class="btn btn-default" data-toggle="modal" data-target="#modal-form">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>新增
</button>
<button id="btn_edit" type="button" class="btn btn-default">
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>修改
</button>
<button id="btn_delete" type="button" class="btn btn-default">
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>删除
</button>
</div>
<table id="tb_departments"></table>
var TableInit = function () {
var oTableInit = new Object();
//初始化Table
oTableInit.Init = function () {
$('#tb_departments').bootstrapTable({
url: '/Active/ActivityS', //请求后台的URL(*)
method: 'post', //请求方式(*)
toolbar: '#toolbar', //工具按钮用哪个容器
striped: true, //是否显示行间隔色
cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
pagination: true, //是否显示分页(*)
sortable: false, //是否启用排序
sortOrder: "asc", //排序方式
queryParams: oTableInit.queryParams,//传递参数(*)
sidePagination: "server", //分页方式:client客户端分页,server服务端分页(*)
pageNumber: 1, //初始化加载第一页,默认第一页
pageSize: 10, //每页的记录行数(*)
pageList: [10, 25, 50, 100], //可供选择的每页的行数(*)
search: true, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
strictSearch: true,
showColumns: true, //是否显示所有的列
showRefresh: true, //是否显示刷新按钮
minimumCountColumns: 2, //最少允许的列数
clickToSelect: true, //是否启用点击选中行
//height: 500, //行高,如果没有设置height属性,表格自动根据记录条数觉得表格高度
uniqueId: "ActivityGuid", //每一行的唯一标识,一般为主键列
showToggle: true, //是否显示详细视图和列表视图的切换按钮
cardView: false, //是否显示详细视图
detailView: false, //是否显示父子表
columns: [{
checkbox: true
},
{
field: 'ActivityGuid',
title: '活动报名主键'
},
{
field: 'Name',
title: '活动名称'
}, {
field: 'Introduction',
title: '活动简介'
}, {
field: 'StartDateTime',
title: '活动开始时间'
}, {
field: 'EndDateTime',
title: '活动结束时间'
},
{
field: 'TotalPlaces',
title: '活动总名额'
},
{
field: 'ActivityType',
title: '活动类型'
},
{
field: 'AccountGuid',
title: '操作人'
},
{
field: 'isLine',
title: '是否上线'
},
{
field: 'isMail',
title: '是否邮寄'
},
]
});
};
//得到查询的参数
oTableInit.queryParams = function (params) {
var temp = { //这里的键的名字和控制器的变量名必须一直,这边改动,控制器也需要改成一样的
limit: params.limit, //页面大小
offset: params.offset, //页码
departmentname: "aa",
statu: "true",
search: params.search
};
return temp;
};
return oTableInit;
};
var ButtonInit = function () {
var oInit = new Object();
var postdata = {};
oInit.Init = function () {
//初始化页面上面的按钮事件
};
return oInit;
};
后台对应的方法
[HttpPost]
public ActionResult ActivityS(int limit, int offset, string activeName, string online, string search)
{
var list = new List<Activitys>();
DataTable dt = bll.GetActivity();
for (int i = 0; i < dt.Rows.Count; i++)
{
Activitys model = new Activitys();
model.ActivityGuid = dt.Rows[i]["ActivityGuid"].ToString();
model.Name = dt.Rows[i]["Name"].ToString();
model.Introduction = dt.Rows[i]["Introduction"].ToString(); model.StartDateTime = Convert.ToDateTime(dt.Rows[i]["StartDateTime"]);
model.EndDateTime = Convert.ToDateTime(dt.Rows[i]["EndDateTime"]); model.TotalPlaces = Convert.ToInt32(dt.Rows[i]["TotalPlaces"]);
model.ActivityType = Convert.ToInt32(dt.Rows[i]["ActivityType"]);
model.AccountGuid = dt.Rows[i]["AccountGuid"].ToString();
model.isLine = dt.Rows[i]["isLine"].ToString() == "1" ? false : true;
model.isMail = dt.Rows[i]["isMail"].ToString() == "1" ? false : true;
list.Add(model);
}
//去除时间带T
var iso = new IsoDateTimeConverter();
iso.DateTimeFormat = "yyyy-MM-dd"; var pageCount = dt.Rows.Count;
var rows = list.Skip(offset).Take(limit).ToList();
return Content(JsonConvert.SerializeObject(new { total = pageCount, rows = rows }, iso));
最终的效果

方便以后可以用到。
bootstrap表格分页的更多相关文章
- Bootstrap表格分页(一)
最近在学习Bootstrap的分页,有一种方法用“Bootstrap-Paginator”的东西来做. 先预览一下: 为了能够局部刷新页面,我创建了一个PartialView 页面的HTML部分如下: ...
- Bootstrap表格分页(二)
本文使用Bootstrap-table来对表格进行分页,关于Bootstrap-table以及下载插件包请点击官网:http://bootstrap-table.wenzhixin.net.cn 首先 ...
- Angular.js+Bootstrap实现表格分页
最近一直学习Angular.js,在学习过程中也练习了很多的Demo,这里先贴一下表格+分页. 先上图看看最终结果: 不得不说Angular.js代码风格很受人欢迎,几十行代码清晰简洁的实现了上面的功 ...
- bootstrap table + spring + springmvc + mybatis 实现从前端到后端的表格分页
1.使用准备 前台需要的资源文件,主要有Bootstrap3相关css.js以及bootstrap Table相关css.js: <-- 样式 --> <link rel=" ...
- 基于Vue.js的表格分页组件
有一段时间没更新文章了,主要是因为自己一直在忙着学习新的东西而忘记分享了,实在惭愧. 这不,大半夜发文更一篇文章,分享一个自己编写的一个Vue的小组件,名叫BootPage. 不了解Vue.js的童鞋 ...
- Vue.js的表格分页组件
转自:http://www.cnblogs.com/Leo_wl/p/5522299.html 有一段时间没更新文章了,主要是因为自己一直在忙着学习新的东西而忘记分享了,实在惭愧. 这不,大半夜发文更 ...
- bootstrap table分页(前后端两种方式实现)
bootstrap table分页的两种方式: 前端分页:一次性从数据库查询所有的数据,在前端进行分页(数据量小的时候或者逻辑处理不复杂的话可以使用前端分页) 服务器分页:每次只查询当前页面加载所需要 ...
- Bootstrap Bootstrap表格插件bootstrap-table配置与应用小结
Bootstrap表格插件bootstrap-table配置与应用小结 by:授客 QQ:1033553122 1. 测试环境 win7 JQuery-3.2.1.min.js 下载地址: h ...
- ThinkPHP 整合Bootstrap Ajax分页
ThinkPHP Ajax分页代码 publicfunction index() { $where=array(); $name = I('name'); if(!empty($name)){ $wh ...
随机推荐
- iOS之ProtocolBuffer搭建和示例demo
这次搭建iOS的ProtocolBuffer编译器和把*.proto源文件编译成*.pbobjc.h 和 *.pbobjc.m文件时,碰到不少问题! 搭建pb编译器到时没有什么问题,只是在把*.pro ...
- Quartz2D总结
天了噜,脑子完全懵了,最起码说出来个上下文啊,连这个都给忘了,特此总结一下,并以此缅怀这次面试 Quartz2D的API来自于Core Graphics(这就是为什么CGContextRef是以CG开 ...
- atitit.attilax的软件 架构 理念.docx
atitit.attilax的软件 架构 理念.docx 1. 预先规划.1 2. 全体系化1 3. 跨平台2 4. 跨语言2 5. Dsl化2 5.1. 界面ui h5化2 6. 跨架构化2 7. ...
- Linux实战教学笔记06:Linux系统基础优化
第六节 Linux系统基础优化 标签(空格分隔):Linux实战教学笔记-陈思齐 第1章 基础环境 第2章 使用网易163镜像做yum源 默认国外的yum源速度很慢,所以换成国内的. 第一步:先备份 ...
- JavaWeb的国际化
国际化 1.国际化开发概述 1.1.软件的国际化 软件开发时,要使它能同时应对世界不同地区和国家的方法,并针对不同地区和国家的方法,提供相应的,符合来访者阅读习惯的页面或数据 国际化简称:i18n : ...
- 从贝叶斯到粒子滤波——Round 1
粒子滤波确实是一个挺复杂的东西,从接触粒子滤波到现在半个多月,博主哦勒哇看了N多篇文章,查略了嗨多资料,很多内容都是看了又看,细细斟酌.今日,便在这里验证一下自己的修炼成果,请各位英雄好汉多多指教. ...
- 使用CocosSharp制作一个游戏 - CocosSharp中文教程
注:本教程翻译自官方<Walkthrough - Building a game with CocosSharp>,官方教程有很多地方说的不够详细,或者代码不全,导致无法继续,本人在看了G ...
- ASP.NET MVC Model绑定(三)
ASP.NET MVC Model绑定(三) 前言 看过前两篇的朋友想必对Model绑定有个大概的了解,然而MVC框架给我们提供了更高的可扩展性的提供程序编程模式,也就是本篇的主题了,会讲解一下Mod ...
- Hibernate整合Spring异常'sessionFactory' or 'hibernateTemplate' is required
今日在写GenericDao时,发现了一个异常,内容如下: org.springframework.beans.factory.BeanCreationException: Error creatin ...
- Redis数据结构详解之Zset(五)
序言 Zset跟Set之间可以有并集运算,因为他们存储的数据字符串集合,不能有一样的成员出现在一个zset中,但是为什么有了set还要有zset呢?zset叫做有序集合,而set是无序的,zset怎么 ...