【发布时间】:2014-09-05 10:31:14
【问题描述】:
我想在网格上将日期显示为 N/A,以防它在数据库中为 NULL,或者以正常日期格式显示。 目前我有这个代码:
name: 'Handshake_Actual_Date', index: 'Handshake_Actual_Date', search: false,
editable:true, align: "left", width: 75, formatter: "date", formatoptions:
{newformat:"m/d/Y" },
editoptions: {
size: 20,
dataInit: function (el) {
$(el).datepicker({ dateFormat: 'mm/d/yy' });
},
defaultValue: function () {
var currentTime = new Date();
var month = parseInt(currentTime.getMonth() + 1);
month = month <= 9 ? "0" + month : month;
var day = currentTime.getDate();
day = day <= 9 ? "0" + day : day;
var year = currentTime.getFullYear();
return day + "/" + month + "/" + year;
}
}
它工作得很好,但我想要一个像下面这样的自定义格式化程序:
function myFormatter (cellvalue, options, rowObject) {
if(cellvalue==null)
{
return "N/A";
}
else
{
return $.fn.fmatter.date(cellvalue, options, rowObject);
}
}
但它不起作用..! 例如,您可以在此处查看代码:http://jsfiddle.net/35Larwva/
【问题讨论】:
标签: jquery jqgrid date-formatting