Kendo DatePicker value(), class Issue

2 posts, 1 answers
  1. Mauro
    Mauro avatar
    4 posts
    Member since:
    Jun 2013

    Posted 21 Aug 2013 Link to this post

    Hi to everyone.
    I have an MVC view with a Kendo DatePicker
                            .HtmlAttributes(new  {style = "width: 150px;" })

    I need to change the date of my element from javascript, and I'm doing it in this way
                    value: new Date(),        
                    format: "dd/MM/yyyy", ( I have to do this because it doesn't remember the given format in the helper )

    It works but this function changes some style in the element, in particular in the first span
    k-input is added causing a padding issue and style has now a width:100%, not 150px as I set in the helper and I have when the page is just opened
    so before
    <span class="k-widget k-datepicker k-header" style="width: 150px;">
    <span class="k-widget k-datepicker k-header k-input" style="width: 100%;">

    I have to use an ugly workaround changing the class and style from jquery but I was wondering if there is a better solution

    any help is appreciated
  2. Answer
    Georgi Krustev
    Georgi Krustev avatar
    3725 posts

    Posted 22 Aug 2013 Link to this post

    Hello Mauro,

    In general, the Kendo widgets are designed to be initialized only once. Any subsequent initializations will modify the html and styling. 
    In order to change the value of the widget after its initialization, you will need to get the instance of the client object and use the value method.

    Georgi Krustev
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top