<link href="<%=path%>/resources/css/bootstrap/bootstrap.min.css" type="text/css" rel="stylesheet"> <link href="<%=path%>/resources/css/bootstrap/bootstrap-table.min.css" type="text/css" rel="stylesheet"> <link rel="stylesheet" type="text/css" href="<%=path%>/resources/css/bootstrap/bootstrap-datetimepicker.min.css"> <link href="<%=path%>/resources/css/bootstrap/bootstrap-editable.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="<%=path%>/resources/js/jquery/jquery-3.2.1.min.js"></script> <script type="text/javascript" src="<%=path%>/resources/js/bootstrap/bootstrap.min.js"></script> <script type="text/javascript" src="<%=path%>/resources/js/bootstrap/bootstrap-table.min.js"></script> <script type="text/javascript" src="<%=path%>/resources/js/bootstrap/bootstrap-table-zh-CN.js"></script> <script type="text/javascript" src="<%=path%>/resources/js/bootstrap/bootstrap-datetimepicker.min.js"></script> <script type="text/javascript" src="<%=path%>/resources/js/bootstrap/bootstrap-editable.min.js"></script> <script type="text/javascript" src="<%=path%>/resources/js/bootstrap/bootstrap-datetimepicker.zh-CN.js"></script> <script type="text/javascript" src="<%=path%>/resources/js/bootstrap/bootstrap-table-editable.js"></script>
$("#table").bootstrapTable({
rowStyle: function (row, index) {//row 表示行数据,object,index为行索引,从0开始
var style = "";
if (row.SignInTime == ‘‘ || row.SignOutTime==‘‘) {
style = { css: { ‘color‘: ‘red‘ } };
}
return style;
},
//searchAlign: ‘left‘,
//search: true, //显示隐藏搜索框
showHeader: true, //是否显示列头
//classes: ‘table-no-bordered‘,
showLoading: true,
undefinedText: ‘‘,
showFullscreen: true,
toolbarAlign: ‘left‘,
paginationHAlign: ‘right‘,
silent: true,
url: url,
method: ‘get‘, //请求方式(*)不要使用post
//toolbar: ‘#toolbar‘, //工具按钮用哪个容器
striped: true, //是否显示行间隔色
cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
pagination: true, //是否显示分页(*)
sortable: false, //是否启用排序
sortOrder: "asc", //排序方式
queryParams: func, //传递参数(*)
sidePagination: "client", //分页方式:client客户端分页,server服务端分页(*)
pageNumber: 1, //初始化加载第一页,默认第一页
pageSize: 10, //每页的记录行数(*)
pageList: [10, 50, 100], //可供选择的每页的行数(*)
search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
strictSearch: true,
showColumns: true, //是否启用手动隐藏列
showRefresh: true, //是否显示刷新按钮
minimumCountColumns: 2, //最少允许的列数
clickToSelect: true, //是否启用点击选中行
//height: 680, //行高,如果没有设置height属性,表格自动根据记录条数觉得表格高度
uniqueId: "id", //每一行的唯一标识,一般为主键列
showToggle: true, //是否显示详细视图和列表视图的切换按钮
cardView: false, //是否显示详细视图
detailView: false, //是否显示父子表
showExport: true,
//exportDataType: ‘all‘,
exportDataType: "selected", //导出checkbox选中的行数
paginationLoop: false, //是否无限循环
showFooter: false,
columns: [{
checkbox: true
}, {
field: ‘rateName‘,
title: ‘费率名称‘,
align: ‘center‘,
editable: {
type: ‘text‘,
title: ‘修改费率名称‘,
validate: function (v) {
if (!v) return ‘费率名称不能为空‘;
}
}
}, {
field: ‘rateValue‘,
title: ‘比率‘,
align: ‘center‘,
editable: {
type: ‘text‘,
title: ‘修改比率‘,
validate: function (v) {
if (!/^((([^0][0-9]+|0)\.([0-9]{1,2}))$)|^(([1-9]+)\.([0-9]{1,2})$)/.test(v)) return ‘比率格式错误‘;
}
}
}, {
field: ‘startDate‘,
title: ‘开始日期‘,
align: ‘center‘,
editable: {
type: ‘date‘,
title: ‘修改开始时间‘
}
}, {
field: ‘endDate‘,
title: ‘结束日期‘,
align: ‘center‘,
editable: {
type: ‘date‘,
title: ‘修改结束日期‘
}
}],
onEditableSave: function (field, row, oldValue, $el) {
$.ajax({
type: "post",
url: "<%=path%>/word/WordC/updateSysRate",
data: row,
success: function () {
buildTable();
},
error: function () {
alert(‘编辑失败‘);
}
});
}
});



@InitBinder
public void initBinder(WebDataBinder binder) {
binder.registerCustomEditor(java.sql.Date.class, new SqlDateEditor());
}
package com.zssi.framework.app.word.editor;
import java.beans.PropertyEditorSupport;
import java.sql.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;
public class SqlDateEditor extends PropertyEditorSupport {
@Override
public void setAsText(String text) throws IllegalArgumentException {
if (text == null || text.equals(""))
return;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date date = null;
try {
date = new Date(sdf.parse(text).getTime());
} catch (ParseException e) {
e.printStackTrace();
}
setValue(date);
}
@Override
public String getAsText() {
return getValue().toString();
}
}
原文:https://www.cnblogs.com/CodeBunny/p/13299213.html