<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<title>Cache Editor for DataGrid - jQuery EasyUI Demo</title>
<link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../../themes/icon.css">
<link rel="stylesheet" type="text/css" href="../demo.css">
<script type="text/javascript" src="../../jquery.min.js"></script>
<script type="text/javascript" src="../../jquery.easyui.min.js"></script>
<script type="text/javascript" src="../../jquery.edatagrid.js"></script>
<script type="text/javascript" src="../../jquery.edatagrid.js"></script>
<script type="text/javascript" src="../../easyui-lang-zh_CN.js"></script>
</head>
<body>
<table id="dg"></table>
<script>
var data2={"total":4,"rows":[
{"filedid":"w1iRaEZjvz8iESYa","a":"第26周(6.25~26)","b":"黄123","qgdate1":"2016/06/25","qgdate2":"2016-06-26"},
{"filedid":"HyzIqJMCKym0DuIx","a":"第25周(6.18~19)","b":"周456","qgdate1":"2016/06/18","qgdate2":"2016-06-19"},
{"filedid":"hNSe07WVKftJDza8","a":"端午节(6.9~11)","b":"粟789","qgdate1":"2016/06/09","qgdate2":"2016-06-11"},
{"filedid":"iDUxrBdDzPf4BOTm","a":"第23周(6.4~6.5)","b":"谢1011","qgdate1":"2016/06/04","qgdate2":"2016-06-05"}
]}
$('#dg').edatagrid({ url:'',
data:data2,
height:"400px", width:"600px",
frozenColumns:[[
{ field: "a", title: "值班标题", width: 130, editor: "text" },
{ field: "qgdate1", title: "开始时间", width: 80, align:"right", editor: "datebox" },
{ field: "qgdate2", title: "结束时间", width: 80, align: "right", editor: "datebox"},
]],
columns: [[
{ field: "filedid", title: "系统识别号", width: 100,hidden:true},
{ field: "b", title: "公司导", width: 80, editor: "text" },
]]
});
$.extend($.fn.datagrid.defaults.editors, {
datebox : {
init : function(container, options) {
var input = $('<input type="text">').appendTo(container);
input.datebox(options);
return input;
},
destroy : function(target) {
$(target).datebox('destroy');
},
getValue : function(target) {
return $(target).datebox('getValue');//获得旧值
},
setValue : function(target, value) {
console.info(value);
$(target).datebox('setValue', value);//设置新值的日期格式
},
resize : function(target, width) {
$(target).datebox('resize', width);
}
}
});
</script>
</body>
</html>
要使用databox中的日期与datagrid中的日期一致,必须要求这两个日期的格式一致,如果不一致,将无法取到,如“2016-6-24”