bootstrap table + spring mvc 服务的分页
来源:互联网 发布:厦门seo公司陈仁潘 编辑:程序博客网 时间:2024/06/05 10:24
<table id='applyNoTable' data-events='operateEvents' ></table>
$("#applyNoTable").bootstrapTable({
// url:"/apply/findByAll", //请求urlmethod: 'get', //服务的必须设置为get
detailView:true, //显示行详细信息
// sidePagination:'server',//设置为服务器端分页
idField:"id", //标识字段
pagination:true, //显示分页
toolbar:"#toolbar", // 工具栏
toolbarAlign:"left", //工具栏位置
queryParamsType:"limit", //请求附带其他参数必须设置为 limit
queryParams:queryParamsfun, //附加参数方法
showRefresh:true, //显示刷新
showColumns:true,//提供选择进行切换显示那些列
iconsPrefix:"fa", //定义是那一种类型的图标
sortName:"id", //默认排序的列
clickToSelect:true, //点击行选中 多选框或单选框
icons:{ //对应的图标样式
detailClose: "fa-minus",
columns:"fa-bars",
refresh:" fa-refresh",
detailOpen: "fa-plus"
},
detailFormatter:detailFormatter, //显示详情的方法
columns: [{checkbox:true},{
field: 'id',
align:"center",
title: '申请编号',
sortable:true, //是否允许排序
order:"asc", //默认排序
visible:true //是否具有收起效果
},{
field: 'userId.id',
align:"center",
title: '用户编号',
visible:false
},{
field: 'userId.loginName',
align:"center",
title: '申请人',
visible:true
}, {
field: 'instance',
align:"center",
visible:true,
title: '实例'
}, {
field: 'io',
align:"center",
title: 'I/O 优化',
visible:true
}, {
field: 'specifications',
align:"center",
visible:true,
formatter:function(value, row, index){
value = '<div class="my-text-overflow">'+value+'</div>';
return value;
},
title: '规格'
}, {
field: 'broadband',
align:"center",
visible:true,
sortable:true,
order:"asc",
title: '宽带'
}, {
field: 'mirror',
align:"center",
visible:true,
title: '镜像'
}, {
field: 'disk',
align:"center",
visible:true,
sortable:true,
order:"asc",
title: '磁盘Gib'
}, {
field: 'number',
align:"center",
visible:true,
title: '数量'
}, {
field: 'operate',
title: '操作',
align: 'center',
events:'operateEvents',
formatter: operateFormatter //最后一列显示内容
}],
onClickRow:function(row,tr){
ids =row.id + "," + ids;
}
});
//查询参数
function queryParamsfun(params){
params['applyYesorNo'] = flag;
params['specifications'] = $("input[name='specifications']").val();
params['io'] = $("input[name='io']").val();
params['instance'] = $("input[name='instance']").val();
params['broadband']= $("input[name='broadband']").val();
params['mirror'] = $("input[name='mirror']").val();
params['disk'] = $("input[name='disk']").val();
params['number'] = $("input[name='number']").val();
params['applyParameter'] = $("#seachApplyLucenu").val();
return params;
}
//点击 + 图标 显示行详细记录
function detailFormatter(index, row) {
var html = [];
$.each(row, function (key, value) {
if(key == "invalid"){
return true;
}
if(key == "userId"){
key = "userName";
value = value.loginName;
}
html.push('<p><b class="col-lg-2">' + key + ':</b> <input type="text" value="' + value + '" disabled/></p>');
});
return html.join('');
}
//每行后面显示操作的列
function operateFormatter(value, row, index) {
if(flag == "已审批"){
return [
'<a class="remove" href="javascript:void(0)" title="删除">',
'<i class="fa fa-times fa-1x"></i>',
'</a>'
].join('');
}
return [
'<a class="like" href="javascript:void(0)" title="处理">',
'<i class="fa fa-pencil-square-o fa-1x"></i>',
'</a> ',
'<a class="remove" href="javascript:void(0)" title="删除">',
'<i class="fa fa-times fa-1x"></i>',
'</a>'
].join('');
}
@RequestMapping("/findByAll")
@ResponseBody
public Object findByAll(Integer limit , Integer offset,final Apply apply,final String applyParameter,String order,String sort){
try {
/* Sort sorts = null;
if("asc".equals(order)){
sorts = new Sort(Sort.Direction.ASC,sort);
}else{
sorts = new Sort(Sort.Direction.DESC,sort);
}*/
apply.setApplyYesorNo("未审批");
List<Apply> findAll = applyDao.findAll(new Specification<Apply>() {
@Override
public Predicate toPredicate(Root<Apply> root, CriteriaQuery<?> query,
CriteriaBuilder cb) {
//path转化
List<Predicate> orPredicates = new ArrayList<Predicate>();
if(applyParameter != null && !("".equals(applyParameter.trim()))){
Join<Apply,User> user = root.join(root.getModel().//
getSingularAttribute("userId", User.class),javax.persistence.criteria.JoinType.LEFT);
Path<String> loginName = user.get("loginName");
Predicate LoginName =cb.like(loginName,"%"+applyParameter+"%");
orPredicates.add(LoginName);
}
//encapsulationSQL 此方法是自己封装的 和上面的if内容一制 ,只是属性不一样
orPredicates = encapsulationSQL(orPredicates, root, cb, apply);
Predicate p = cb.and(orPredicates.toArray(new Predicate[orPredicates.size()]));
query.where(p);
return null;
}
});
/*
ObjectMapper objectMapper = new ObjectMapper();
String str = objectMapper.writeValueAsString(findAll.getContent());
String strApply = JsonUtil.getJson(String.valueOf(findAll.getTotalElements()), str);*/
return findAll;
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
- bootstrap table + spring mvc 服务的分页
- 使用spring-mvc,bootstrap-table插件实现分页
- bootstrap-table 分页的问题
- bootstrap-table 分页的问题
- bootStrap table spring mvc 详细运用实例
- spring mvc +bootstrap+datatable实现分页
- spring mvc ajax分页 bootstrap-paginator
- Spring MVC下 bootStrap服务器分页代码
- Struts2结合Bootstrap-Table分页的使用
- bootstrap table + spring + springmvc + mybatis 实现从前端到后端的表格分页
- bootStrap table实现分页
- BootStrap-Table 分页
- Bootstrap Table分页例子
- bootstrap-table后端分页
- bootstrap-table分页问题
- bootstrap table 分页
- bootstrap table 分页例子
- BootStrap table分页
- 白手起家学习数据科学 ——线性回归之“简单线性回归篇”(十一)
- android ui测试uiautomator
- tomcat设置内存溢出配置
- <LeetCode OJ> 258. Add Digits
- Nodejs socket.io 实现私聊:如何给指定客户端发送消息,不是群广播
- bootstrap table + spring mvc 服务的分页
- Maven多环境配置实战 filter
- android 开发人员须了解的开发者选项
- Semaphore 控制并发访问线程数
- 提交代码的步骤
- Android上常见度量单位【xdpi、hdpi、mdpi、ldpi】解读
- android码农神器 偷懒工具 android懒人框架 LoonAndroid 3 讲解
- wordpress nginx 屏蔽后台密码破解 xmlrpc.php
- Java线程篇(四):线程的中断、让步、睡眠、合并