Date Formatting

3 posts, 0 answers
  1. Barrie
    Barrie avatar
    3 posts
    Member since:
    Jan 2014

    Posted 18 Feb 2014 Link to this post

    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. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 20 Feb 2014 Link to this post

    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!
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Barrie
    Barrie avatar
    3 posts
    Member since:
    Jan 2014

    Posted 20 Feb 2014 Link to this post

    Great, thanks.

    What was confusing was that the other properties of PaperListItem worked just fine!
Back to Top