Setting Text of RadDatePicker/RadTimePicker client side

2 posts, 0 answers
  1. Sean
    Sean avatar
    1 posts
    Member since:
    Jun 2008

    Posted 28 Sep 2008 Link to this post

    Hello,

    To improve page rendering performance on a page with alot of date/time input fields, I'm trying to dynamically replace standard input textboxes with raddate/timepickers as the textboxes are selected, however I'm having trouble setting the text inside the date/time pickers.  As soon as the picker gets focus it replaces the value in its textbox with whatever the selected datetime is.  I need the value to "stick" when the picker gets focus, even if it is not valid.

    Here's the code I'm using right now:

    <input type="text" onfocus="onTimeInputFocus(this);"/> 
     
    <script type="text/javascript" language="javascript"
                    var replacedElement = null
     
                    function onTimeInputFocus(input) 
                    { 
                        timepicker = getNinjaTimePickerObject(); 
                         
                        timepickerEl = getNinjaTimePickerElement(); 
                        if ( replacedElement ) 
                        { 
                            replacedElement.value = timepicker.get_textBox().value; 
                            timepickerEl.parentNode.replaceChild(replacedElement, timepickerEl); 
                        } 
                        else 
                        { 
                            timepickerEl.parentNode.removeChild(timepickerEl); 
                        } 
                        replacedElement = input.parentNode.replaceChild(timepickerEl, input); 
                         
                        timepicker.get_textBox().value = replacedElement.value; 
                        //setTimeout( "timepicker.get_textBox().focus();", 100 ); 
                    } 
                     
                    function getNinjaTimePickerElement() 
                    { 
                        return document.getElementById("<%= NinjaTimePicker.ClientID %>"  + "_wrapper"); 
                    } 
                     
                    function getNinjaTimePickerObject() 
                    { 
                        return $find("<%= NinjaTimePicker.ClientID %>"); 
                    } 
    </script> 


    I know I can always parse the datetime represented in the textbox and then call set_selectedDate() on the picker, but I need to be able to set values with invalid formats as well, and it would be nice if I could rely on the parsing mechanism inside the picker.
  2. Plamen Peshev
    Admin
    Plamen Peshev avatar
    885 posts

    Posted 29 Sep 2008 Link to this post

    Hello Sean,


    To see more information on the requested functionality, please refer to the following article:


    Getting and Setting Values

    Best wishes,
    Plamen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top