1

I am working on following example: http://dojo.telerik.com/InEyo

In this example I set the date for the data input to

var date = "2013-10-10 14:02:40.44";

To read the date I use the following where my Date column is defined:

format: "{0:dd-MMM-yyyy HH:mm:ss}",
parseFormats: ["yyyy-MM-dd' 'HH:mm:ss.zz"]

parseFormats defines the format of the input string and format defines how I want to display it (to my understanding). I have my example from Kendo grid format time issue in date column

The example above works - as it should!

My problem (http://dojo.telerik.com/aqafE): The date I get from the database is formatted like this: "20131010 140240" - so "yyyyMMdd HHmmss".

Naturally I would adjust the parseFormats like this:

format: "{0:dd-MMM-yyyy HH:mm:ss}",
parseFormats: ["yyyyMMdd' 'HHmmss"]

However this does not output the date so I assume either I have made a mistake in defining the input string or the string from the database just does not work with Kendo...

Any ideas? Thanks

Community
  • 1
  • 1
DavidDunham
  • 1,245
  • 1
  • 22
  • 44
  • "20131010 140240" is invalid date. try it to convert into jQuery Date using, new Date("20131010 140240") – 111 Apr 08 '15 at 09:41
  • I assume that when I am using "parseFormats" which defines the input format it does not need to be a valid date string. Like $.datepicker.parseDate( format, value, options ) – DavidDunham Apr 08 '15 at 14:58

1 Answers1

2

All you need to do in your example is change how your datasource schema defines your model rather than trying to do it on the grid column.

So go from this:

schema: {
    model: {
        fields: {
            Id       : { type: 'number' },
            FirstName: { type: 'string' },
            LastName : { type: 'string' },
            Date: { type: 'date'},
        }
    }
}

To this:

schema: {
    model: {
        fields: {
            Id       : { type: 'number' },
            FirstName: { type: 'string' },
            LastName : { type: 'string' },
            Date     : { type: 'date',
                         parse: function(date) {
                             return kendo.parseDate(date,"yyyyMMdd HHmmss");
                         }
                       }
        }
    }
}

Edit: Here's a fiddle link: http://dojo.telerik.com/aqafE/3

Brian King
  • 51
  • 1
  • 4