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

Date Formatting

2 Answers 191 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Barrie
Top achievements
Rank 1
Barrie asked on 18 Feb 2014, 09:55 AM
I have a ListView control which uses a client template something like:

<script type="text/x-kendo-tmpl" id="paperlist-template">
  ...
  <div>${kendo.toString(PublicationDate, "dd MMMM yyyy")}</div>
  ...
</script>

If I construct the ListView using:

@(Html.Kendo().ListView(Model.Papers)...

everything works fine and the dates display correctly.  Model.Papers is an IEnumerable<PaperListItem>.  PaperListItem.PublicationDate is a C# DateTime.

However, if I construct the ListView using:

@(Html.Kendo().ListView<IEnumerable<PaperListItem>>()...

the dates come out like "/Date(1382050800000)/".

Why is that?

2 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 20 Feb 2014, 08:35 AM
Hello Barrie,

You should use the type of the model as generic parameter for the ListViewBuilder:
Html.Kendo().ListView<PaperListItem>()
The enumeration does not have a property PublicationDate of type DateTime and therefore the type will not be known and the value will not be parsed.

Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Barrie
Top achievements
Rank 1
answered on 20 Feb 2014, 08:44 AM
Great, thanks.

What was confusing was that the other properties of PaperListItem worked just fine!
Tags
ListView
Asked by
Barrie
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Barrie
Top achievements
Rank 1
Share this question
or