DateTimePicker inside a Kendo Template

3 posts, 1 answers
  1. Kevin
    Kevin avatar
    22 posts
    Member since:
    Feb 2014

    Posted 11 Nov 2015 Link to this post



    I've placed an MVC wrapped DateTimePicker inside a kendo template, but the problem I'm having is setting the value.  Here's the code I'm using:


                    .Min(new System.DateTime(1970, 1, 1, 0, 0, 0)) // Epoch
                    .Format("MM-dd-yyyy HH:mm")
                    .HtmlAttributes(new { style = "width:100%" })
                    .Value("#: kendo.toString(ActiveDT, 'MM-dd-yyyy HH:mm') #")

     This loads a DateTimePicker inside the list view, however the value of the picker is always blank.  I've tried a few things to fix it (deferring, outputting a javascript date object instead of a string, changing everything to create the datetimepicker through javascript rather than the wrapper) and I'm at a bit of a dead end, I was just wondering where exactly I'm going wrong.




  2. Answer
    Daniel avatar
    2177 posts

    Posted 13 Nov 2015 Link to this post

    Hello Kevin,

    The Value method expects a DateTime value or a string that can be converted to DateTime on the server which will not be the case because the ClientTemplate is evaluated on the client. It should be possible to set the value with a template expression by setting the string to the value attribute using HtmlAttributes method:
    .HtmlAttributes(new { style = "width:100%", value = "#: kendo.toString(ActiveDT, 'MM-dd-yyyy HH:mm') #"})

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Kevin
    Kevin avatar
    22 posts
    Member since:
    Feb 2014

    Posted 13 Nov 2015 in reply to Daniel Link to this post

    That worked perfectly, thanks Daniel!


Back to Top