4

I have a kendo grid, it has a date column. I want to show date and time there. I am using below format in column definition,

format: "{0:dd-MMM-yyyy hh:mm:ss tt}"

In modal I used date type Updated_Date: { type: "date" }

Output date is coming as '10-Oct-2013 12:00:00 AM', but actual date returned via ajax call is "Updated_Date":"2013-10-10T05:02:40.44"

What to do to show the correct time in Grid like 10-Oct-2013 05:02:40 AM?

4

2 回答 2

9

There are two fields that are commonly confused:

  • format : Specifies the format, which is used to format the value of the DateTimePicker displayed in the input.
  • parseFormats: Specifies the formats, which are used to parse the value set with value() method or by direct input.

So actually you need to define a parseFormat because of the T between date and time that makes the format not being a default one:

Try:

columns   : [
    ...
    {
        field       : "Date",
        title       : "Date",
        format      : "{0:dd-MMM-yyyy hh:mm:ss tt}",
        parseFormats: ["yyyy-MM-dd'T'HH:mm:ss.zz"]
    }
]

Running example here : http://jsfiddle.net/OnaBai/Ahq6s/

于 2013-10-11T13:09:24.073 回答
3

Just had the exact same problem. It is because the grid is not recognising the field as a date. You need to add the "type" as follows:

columns   : [
...
{
    field       : "Date",
    title       : "Date",
    type        : "date",
    format      : "{0:dd-MMM-yyyy hh:mm:ss tt}",
    parseFormats: ["yyyy-MM-dd'T'HH:mm:ss.zz"]
}

]

于 2014-02-19T12:09:12.353 回答