2013-02-06 119 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對象的屬性時纔是正確的。如果你這樣做,那麼你應該包括完整的代碼,它顯示你所做的。如果您僅在您懷疑存在錯誤的位置發佈代碼片段,則無法在代碼中找到錯誤。最好的辦法是發佈可用於重現問題的完整代碼。

相關問題