<!--頁面部分-->javascript
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<meta charset="UTF-8">
<title>Column Group - jQuery EasyUI Demo</title>
<link rel="stylesheet" type="text/css" href="resources/js/easyui-1.5.2/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="resources/js/easyui-1.5.2/themes/icon.css">
<link rel="stylesheet" type="text/css" href="resources/js/easyui-1.5.2/demo.css">
<script type="text/javascript" src="resources/js/easyui-1.5.2/jquery.min.js"></script>
<script type="text/javascript" src="resources/js/easyui-1.5.2/jquery.easyui.min.js"></script>
<script type="text/javascript" src="resources/js/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="resources/js/dwView.js?time=<%=new Date().getTime()%>"></script>
<!–[if lt IE 7]>
<script type="text/JavaScript" src="resources/js/json2.js"></script>
<![endif]–>
<title>客戶池</title>
<body>
<div id="searchtb" style="padding:6px;height:auto">
<table>
<tr>
<td>
<input class="easyui-textbox" id="pstxt"
value="客戶名稱、物料編碼" style="width: 350px;color:#A4A4A4""></input>
</td>
<td>
<input id="d4311" type="text" class="easyui-datebox" size="13px;" >到
<input id="d4312" type="text" class="easyui-datebox" size="13px;"></input>
</td>
<td>
<input type="button" onclick="search()" value="查詢" />
</td>
</tr>
</table>
</div>
<table id="dwDatagrid">
</table>
</body>
</html>css
<!--js 部分-->html
/**日期顯示格式化*/
function formartDate(id){
$('#'+id).datebox({
onShowPanel : function() {// 顯示日趨選擇對象後再觸發彈出月份層的事件,初始化時沒有生成月份層
span.trigger('click'); // 觸發click事件彈出月份層
if (!tds)
setTimeout(function() {// 延時觸發獲取月份對象,由於上面的事件觸發和對象生成有時間間隔
tds = p.find('div.calendar-menu-month-inner td');
tds.click(function(e) {
e.stopPropagation(); // 禁止冒泡執行easyui給月份綁定的事件
var year = /\d{4}/.exec(span.html())[0]// 獲得年份
, month = parseInt($(this).attr('abbr'), 10) + 1; // 月份
$('#'+id).datebox('hidePanel')// 隱藏日期對象
.datebox('setValue', year + '-' + month); // 設置日期的值
});
}, 0);
},
parser : function(s) {// 配置parser,返回選擇的日期
if (!s)
return new Date();
var arr = s.split('-');
return new Date(parseInt(arr[0], 10), parseInt(arr[1], 10) - 1, 1);
},
formatter : function(d) {
if (d.getMonth() == 0) {
return d.getFullYear()-1 + '-' + 12;
} else {
return d.getFullYear() + '-' + d.getMonth();
}
}// 配置formatter,只返回年月
});
var p = $('#'+id).datebox('panel'), // 日期選擇對象
tds = false, // 日期選擇對象中月份
span = p.find('span.calendar-text'); // 顯示月份層的觸發控件
}java
/***
* 生成列頭部分
*/
$(document).ready(function () {
formartDate('d4311');
formartDate('d4312');
});jquery