在 JqGrid 中格式化添加 LocalDate
Formatting Joda LocalDate in JqGrid
我正在尝试在我的 jqGrid 中转换 jodaDateFormat。
我的实体 class 中的声明是:
@Type(type="org.jadira.usertype.dateandtime.joda.PersistentLocalDate")
@DateTimeFormat(iso=ISO.DATE)
@Column(nullable=false)
private LocalDate dateStart;
为了在视图中看到这个日期,我尝试在 tagx 文件中插入这个 javascript 转换:
<script type="text/javascript">
<![CDATA[
jodaLDFormatter = function (cellValue, options) {
if(cellValue) {
return $.datepicker.formatDate(
'dd/MM/yyyy',
new Date(cellValue['year'],
cellValue['monthOfYear']-1,
cellValue['dayOfMonth']));
} else {
return '';
}
};
在 JSP 页面中,我以这种方式声明列:
<table:jqcolumn id="l_list_dateStart" property="dateStart" formatter="jodaLDFormatter"/>
但我得到了这个:(来自页面的来源)
<td role="gridcell" style="" title="NaN/NaN/NaNNaN" aria-describedby="l_list_dateStart">NaN/NaN/NaNNaN</td>
我不想转换字符串中的每个日期以便在 jqGrid 中查看它!
正确的方法是什么?!
我认为您没有将 Joda 对象传递给视图。可能你从你的控制器发送了一个向量,比如 [day, month, year]
.
如果我的猜测是正确的,你可以在你的 colmodel
:
中添加这个
formatter: 'date', srcformat:'dd/mm/yy', date:'true'
我正在尝试在我的 jqGrid 中转换 jodaDateFormat。
我的实体 class 中的声明是:
@Type(type="org.jadira.usertype.dateandtime.joda.PersistentLocalDate")
@DateTimeFormat(iso=ISO.DATE)
@Column(nullable=false)
private LocalDate dateStart;
为了在视图中看到这个日期,我尝试在 tagx 文件中插入这个 javascript 转换:
<script type="text/javascript">
<![CDATA[
jodaLDFormatter = function (cellValue, options) {
if(cellValue) {
return $.datepicker.formatDate(
'dd/MM/yyyy',
new Date(cellValue['year'],
cellValue['monthOfYear']-1,
cellValue['dayOfMonth']));
} else {
return '';
}
};
在 JSP 页面中,我以这种方式声明列:
<table:jqcolumn id="l_list_dateStart" property="dateStart" formatter="jodaLDFormatter"/>
但我得到了这个:(来自页面的来源)
<td role="gridcell" style="" title="NaN/NaN/NaNNaN" aria-describedby="l_list_dateStart">NaN/NaN/NaNNaN</td>
我不想转换字符串中的每个日期以便在 jqGrid 中查看它!
正确的方法是什么?!
我认为您没有将 Joda 对象传递给视图。可能你从你的控制器发送了一个向量,比如 [day, month, year]
.
如果我的猜测是正确的,你可以在你的 colmodel
:
formatter: 'date', srcformat:'dd/mm/yy', date:'true'