timejqgridfree-jqgridjqgrid-formatter

free jqgrid - date formatter newformat with time always invalid


My attempts to use "newformat": "Y-m-d H:i:s" in date formatoptions always returns the invalid date warning when I try to add or edit new row with correct data (including time, example: 2018-01-01 07:00:00) in this field.

formatter: "date", formatoptions: { "srcformat": "ISO8601Long", "newformat": "Y-m-d H:i:s" }

Can anybody help me to get this working properly?

JSFIDDLE: link


Solution

  • The reason of the problem is the usage of editrules:{date:true} in your demo. The validation rule date:true can be used in jqGrid only in case of usage of date without time.

    I'd recommend you to remove editrules:{date:true} or to use custom validation of data instead. You can use custom validation in the old style using editrules:{custom:true, custom_func: function(value,name,iCol) {...}} (see here) or to use new style of custom callback function: editrules:{custom: function(options) {...}}. In case of positive validation the callback function should return [true, ""] or [true]. In case of validation error the return value should be [false, "your error message"];