2013-02-06 120 views
1

我正在通过在自定义格式化程序中扩展jqgrid fmatter来进行日期格式设置。如果我这样做,那么“查找”功能不起作用。以下是示例colModel和自定义格式化函数。如果日期格式化在jqgrid中的自定义格式化程序中完成,找不到工作

colModel = {name:currentLevelInDate, label:"Period Beginning (GMT)", index:currentLevelInDate,sorttype: "date",datefmt: datefmt, formatter:"formatDate", 
unformat: 'unformatDate', formatoptions: { newformat:newFormat, srcformat:srcFormat}} 

formatDate : function(cellvalue, opts, rowObject) { 
... 
... 
var op = $.extend({}, $.jgrid.formatter.date); 
if(opts.colModel.formatoptions != undefined) { 
    op = $.extend({}, op, opts.colModel.formatoptions); 
} 

cellDisplayValue = $.fmatter.util.DateFormat(op.srcformat,cellvalue,op.newformat,op); 
.... 

return cellDisplayValue; 
} 

回答

0

您应该发布更完整的代码,您使用。例如,使用变量datefmtnewFormat,srcFormat,但不包括变量的定义。在你的代码

一个明显的错误是函数名称中使用为字符串:

formatter: "formatDate" 

,而不是使用变量:formatter: formatDate。语法formatter: "formatDate"只有在formatDate被定义为$.fn.fmatter对象的属性时才是正确的。如果你这样做,那么你应该包括完整的代码,它显示你所做的。如果您仅在您怀疑存在错误的位置发布代码片段,则无法在代码中找到错误。最好的办法是发布可用于重现问题的完整代码。

相关问题