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

[Solved] KendoAngular - Grid with column DateTime and kendo.parseDate not working

1 Answer 651 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sagar
Top achievements
Rank 1
Sagar asked on 29 Oct 2014, 01:38 PM
Hi,

We are using angularJS and on a page we have a grid. One of the columns in the grid we are supposed to show DateTime. From the service we are getting the data in milliseconds, like:  "myNewDate":1408441123075

So for the column in the grid options we:

{
     field: "myNewDate",
     title: "Date and Time",
     width: "15%",
     type: "date",
     template: "#= kendo.toString(kendo.parseDate(myNewDate, 'yyyy-MM-dd HH:mms'), 'MM-dd-yyyy HH:mms') #"
}

But it is giving us an error on kendo.parseDate. We would like to show not only the Date but also the time in hours and seconds. The way we are assigning
data to the grid is by having an object of DataSource (kendo.data.DataSource).

Can you please let us know how shall we go about it?

Appreciate your quick help on this.

Thanks!

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 31 Oct 2014, 09:27 AM
Hello Sagar,

Looking at the provided snippet I guess that the error is due to incorrect arguments. As you may know the kendo.parseDate expects a string value which to be parsed and optionally the format in which the date in the string value is represented. However, in your snippet the value is number and the format pattern does not match. It seems that the value you are trying to parse is a tick representation of the Date, if this is the case you may use the Date object constructor to build the date, similar to the following:

template: "#= kendo.toString(new Date(myNewDate), 'MM-dd-yyyy HH:mms') #"


Regards,
Rosen
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
Sagar
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or