Bootsrap Table表格分页
一 bootsrap简介
Bootstrap,来自 Twitter,是目前很受欢迎的前端框架。Bootstrap 是基于 HTML、CSS、JAVASCRIPT 的,它简洁灵活,使得 Web 开发更加快捷。
它由Twitter的设计师Mark Otto和Jacob Thornton合作开发,是一个CSS/HTML框架。Bootstrap提供了优雅的HTML和CSS规范,它即是由动态CSS语言Less写成。Bootstrap一经推出后颇受欢迎,一直是GitHub上的热门开源项目,包括NASA的MSNBC(微软全国广播公司)的Breaking News都使用了该项目。
简介不介绍过多,相信用过的人都知道boostrap的好处。多浏览器兼容性、页面美观、提供一整套的样式解决方案、基于H5+CSS3,对移动应用提供了非常好的支持...
二 配置文件
- <script src="../js/jquery.1.11.3.min.js"></script>
- <script src="../js/bootstrap.js"></script>
- <script src="../js/bootstrap-table.js"></script>
- <link rel="stylesheet" href="../css/bootstrap.min.css" />
- <link rel="stylesheet" href="../css/bootstrap-table.css" />
boostrap基于jquery开发而成,需要在head中最先引入jquery,再进行其他boostrap的js包的引入。在bootsrap3以后,支持模块化导入包,针对自己使用的功能,导入必要的js包,可以有效的减少页面的资源加载量。
三 Boostrap Table配置
html
Boostrap通过解析服务端返回的json对象,与table的data-field进行比对,如果名字相同,则取对应的数据进行展现。
可以通过data-formatter属性指定的js方法对服务端返回的数据进行相应的格式化,此例中使用了boostrap的图标,例如:<span class="glyphicon glyphicon-credit-card"></span>,不允许在boostrap图标的<span>标签内添加内容。
- <div class="table-responsive tableDIV">
- <table class="table table-striped table-no-bordered table-hover"
- id="accountTable" data-toggle="accountTable" data-height="400">
- <thead>
- <tr>
- <th data-field="name" data-formatter="accFormatterName"><span class="glyphicon glyphicon-user"></span> 企业名称/姓名</th>
- <th data-field="mobile" ><span class="glyphicon glyphicon-phone"></span> 手机号</th>
- <!-- <th data-field="email" ><span class="glyphicon glyphicon-envelope"></span> 邮箱</th> -->
- <th data-field="code" data-formatter="FormatterNoOrCode"> <span class="glyphicon glyphicon-credit-card"></span> 身份证/组织机构代码证</th>
- <th data-field="company" data-formatter="FormatterOrgan" ><span class="glyphicon glyphicon-home" ></span> 所属公司</th>
- <th data-field="createDate" ><span class="glyphicon glyphicon-calendar"></span> 导入日期</th>
- <th data-field="tagName" ><span class="glyphicon glyphicon-list"></span> 用户组</th>
- <th data-field="status" data-formatter="FormatterStatus"><span class="glyphicon glyphicon-th-large"></span> 实名状态</th>
- <th data-field="" data-formatter="FormatterOperate" class="col-md-2"><span class="glyphicon glyphicon-briefcase"></span> 操作</th>
- <th data-field="accountUid" class="hidden"></th>
- <th data-field="tagrefIds" class="hidden"></th>
- <th data-field="tagId" class="hidden"></th>
- </tr>
- </thead>
- </table>
- </div>
JS
服务端分页需要指定sidePagination 值为true, 同时可以指定对应的查询参数,内置的分页查询参数包括offset、limit等。
- function getAccountTab() {
- $("#accountTable").bootstrapTable({
- method : 'get',
- url : "../rest/api/account/query",
- pagination : true,
- pageList : [5, 8 ],
- search : false,
- showColumns : false,
- sidePagination : "server", //服务端请求
- queryParams : 'queryParams',
- pageSize : 8,
- pageNumber : 1,
- clickToSelect : true,
- singleSelect: true,
- paginationFirstText : "第一页",
- paginationPreText : "上一页",
- paginationNextText : "下一页",
- paginationLastText : "最后一页",
- onLoadSuccess : function(data) {
- },
- onLoadError : function(data) {
- },
- onCheck: function (row) {
- },
- onCheckAll: function(rows){
- },
- onCheckSome: function(rows){
- },
- onUncheck:function(row){
- },
- onUncheckAll:function(){
- delArray = new Array();
- }
- });
- }
- //设置传入参数
- function queryParams(param) {
- return {
- limit : param.limit,
- offset : param.offset,
- name : $('#accountName').val(),
- mobile : $('#accountMobile').val(),
- email : $('#accountEmail').val(),
- organize : $('#accountOrganize').val(),
- type : $('#accountType option:selected').val(),
- tagId: $('#user_tag option:selected').val()
- };
- }
后端
- @GET
- @Path("/query")
- @Produces(MediaType.APPLICATION_JSON)
- public String queryAccount(@QueryParam("limit") final int limit,
- @QueryParam("offset") final int offset,
- @QueryParam("name") final String name,
- @QueryParam("mobile") final String mobile,
- @QueryParam("email") final String email,
- @QueryParam("organize") final String organize,
- @QueryParam("order") final String order,
- @QueryParam("type") final int type,
- @QueryParam("tagId") final String tagId) {
- final String accountUid = (String) request.getSession().getAttribute(
- ACCOUNTUID);
- final BasePageResponse response = this.accountService
- .findPageBySelector(offset, limit, type, name, email, 0,
- mobile, accountUid, tagId);
- final List<AccountManagerData> accs = BeanConvertUtil
- .getAccountBeans(response);
- final JsonConfig jsonConfig = new JsonConfig();
- jsonConfig.registerJsonValueProcessor(Date.class,
- new JsonDateValueProcessor("yyyy-MM-dd HH:mm:ss"));
- final JSONArray array = JSONArray.fromObject(accs, jsonConfig);
- final JSONObject jsonObj = new JSONObject();
- jsonObj.put("rows", array.toString());
- jsonObj.put("total", response.getTotalCount());
- return jsonObj.toString();
- }
采用jersey进行数据接收以及业务处理返回相应数据,使用struts2或者springMVC也同样可以,只需要按照boostrap的要求,对返回的json对象中包含rows、total这两项数据。
对应实现的效果
四 资料下载
Boostrap-table下载,包括table js以及相对应的boostrap-table的API,以及对应的部分示例。
http://bootstrap-table.wenzhixin.net.cn/examples/
Boostrap中文网官网、API
希望大家相互指正,有需要共同讨论!
Bootsrap Table表格分页的更多相关文章
- MySQL+Service+Servlet+Jsp实现Table表格分页展示数据
下面以一个示例讲解如何使用MySQL+Service+Servlet+Jsp实现Table表格分页展示数据: eg:请假管理系统 要求如下: 一.打开首页页面, 访问查询请假记录的 servlet , ...
- bootstrap table + spring + springmvc + mybatis 实现从前端到后端的表格分页
1.使用准备 前台需要的资源文件,主要有Bootstrap3相关css.js以及bootstrap Table相关css.js: <-- 样式 --> <link rel=" ...
- 基于Vue.js的表格分页组件
有一段时间没更新文章了,主要是因为自己一直在忙着学习新的东西而忘记分享了,实在惭愧. 这不,大半夜发文更一篇文章,分享一个自己编写的一个Vue的小组件,名叫BootPage. 不了解Vue.js的童鞋 ...
- [js开源组件开发]table表格组件
table表格组件 表格的渲染组件,demo请点击http://lovewebgames.com/jsmodule/table.html,git源码请点击https://github.com/tian ...
- Vue.js的表格分页组件
转自:http://www.cnblogs.com/Leo_wl/p/5522299.html 有一段时间没更新文章了,主要是因为自己一直在忙着学习新的东西而忘记分享了,实在惭愧. 这不,大半夜发文更 ...
- Angular.js+Bootstrap实现表格分页
最近一直学习Angular.js,在学习过程中也练习了很多的Demo,这里先贴一下表格+分页. 先上图看看最终结果: 不得不说Angular.js代码风格很受人欢迎,几十行代码清晰简洁的实现了上面的功 ...
- 【转】基于jquery的无刷新表格分页
效果图 css样式 <style> html,body{margin: 0;padding:0} a:focus {outline: none;} /* 通用表格显示 */ table, ...
- ASP.NET MVC 之表格分页
简单效果图:(框架:MVC+NHibernate) 要点: (1)首先建立表格分页Model(GridModel.cs) (2)然后建立数据展示页(PageCloth.cshtml) (3)再建分页版 ...
- layui table 表格模板按钮实例
这是个是全部的jsp 页面: <%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8& ...
随机推荐
- Hexo下Next主题配置与优化
使用Next主题 在这里Downloads Next主题代码 将下载的代码放在myBlog/theme/next目录下 设置站点myBlog/_config.yml的theme字段值为next 生成新 ...
- 使用穷人版profiler定位调试MySQL
此文已由作者温正湖授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 周末闲得蛋疼,来英飞特做人工空气净化器.开了电脑后,习惯性得点击xshell按钮,进入InnoSQL稳定性测 ...
- JavaScript 测试和捕捉(try与catch)
JavaScript 测试和捕捉 try 语句允许我们定义在执行时进行错误测试的代码块. catch 语句允许我们定义当 try 代码块发生错误时,所执行的代码块. JavaScript 语句 try ...
- 转场动画CALayer (Transition)
1.将对应UI控件的层调用以下接口即可 1.1 .h文件 // // 文 件 名:CALayer+Transition.h // // 版权所有:Copyright © 2018年 leLight. ...
- day03-Linux操作系统目录结构
一. Linux系统目录表示 ‘/’表示根目录: ‘.’表示当前目录 ...
- nginx 简单教程
使用 nginx 的使用比较简单,就是几条命令. 常用到的命令如下: nginx -s stop 快速关闭Nginx,可能不保存相关信息,并迅速终止web服务. nginx -s quit 平稳关闭N ...
- 「BZOJ1010」[HNOI2008] 玩具装箱toy(斜率优化)
P教授要去看奥运,但是他舍不下他的玩具,于是他决定把所有的玩具运到北京.他使用自己的压缩器进行压缩,其可以将任意物品变成一堆,再放到一种特殊的一维容器中.P教授有编号为 1⋯N1\cdots N1⋯N ...
- P4172 [WC2006]水管局长 LCT维护最小生成树
\(\color{#0066ff}{ 题目描述 }\) SC 省 MY 市有着庞大的地下水管网络,嘟嘟是 MY 市的水管局长(就是管水管的啦),嘟嘟作为水管局长的工作就是:每天供水公司可能要将一定量的 ...
- CF708B Recover the String 构造
For each string s consisting of characters '0' and '1' one can define four integers a00, a01, a10 an ...
- linux下将当前目录下的文件名存到一个文本文件里
如果只是想得到当前目录下(不包括子目录)的相关文件时:ls -l | grep ".gz$" > 1.txt 如果想得到当前目录下,包括子目录中的相关文件时,应该用find ...