This is a migrated thread and some comments may be shown as answers.

[Solved] Kendo Grid Date Input Output not properly working

1 Answer 205 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Markus
Top achievements
Rank 1
Markus asked on 08 Apr 2015, 02:59 PM

Hi

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 http://stackoverflow.com/questions/19316687/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...

Many thanks

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 10 Apr 2015, 07:41 AM
Hi Markus,

The problems is that the format you are using is not a default one. You need to parse it via code. Here is an updated version of your demo: http://dojo.telerik.com/@korchev/aZUqo

The date parsing happens in the model field definition:
                      model: {
                                    fields: {
                                        Id       : { type: 'number' },
                                        FirstName: { type: 'string' },
                                        LastName : { type: 'string' },
                                        Date: { 
                                          type: 'date', 
                                          parse: function(value) {
                                            return kendo.parseDate(value, "yyyy-MM-dd HH:mm:ss");
                                          } 

                                        }
                                    }
                                }
                            }


Regards,
Atanas Korchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Markus
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or