jQuery.extend($.fn.fmatter, {
fmatterNotice : function (cellvalue, options, rowObject) { // 格式化状态值
var nowDate = new Date();
var noticeDate = rowObject.NOTICE_DATE;
var validityDate = rowObject.VALIDITY_DATE;
noticeDate=noticeDate.replace(/-/g,"/");//替换字符,变成标准格式
var _noticeNewDate=new Date(Date.parse(noticeDate));
var year1=_noticeNewDate.getFullYear();
var month1=_noticeNewDate.getMonth();
var day1=_noticeNewDate.getDate();
var noticeNewDate=new Date(year1,month1,day1,15,00,00);
validityDate=validityDate.replace(/-/g,"/");//替换字符,变成标准格式
var _validityNewDate=new Date(Date.parse(validityDate));
var year2=_validityNewDate.getFullYear();
var month2=_validityNewDate.getMonth();
var day2=_validityNewDate.getDate();
var validityNewDate=new Date(year2,month2,day2,15,00,00);
if((nowDate.valueOf()>=noticeNewDate.valueOf()) && (nowDate.valueOf()<=validityNewDate.valueOf()))
{
return "<font color='green'>即将到期</font>";
}else if(nowDate.valueOf() > validityNewDate.valueOf()){
return "<font color='red'>已过期</font>";
}else{
return "<font color='#aacc28'>即将提醒</font>";
}
}
});
在jqgrid表单上。
本文介绍了一个使用jQuery扩展的方法,该方法能够根据当前日期与预设的提醒和有效期日期对比,来格式化显示表格中项的状态,如“即将到期”、“已过期”或“即将提醒”。

被折叠的 条评论
为什么被折叠?



