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

Setting Text of RadDatePicker/RadTimePicker client side

1 Answer 172 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Sean
Top achievements
Rank 1
Sean asked on 28 Sep 2008, 03:13 PM
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.

1 Answer, 1 is accepted

Sort by
0
Missing User
answered on 29 Sep 2008, 07:09 AM
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.
Tags
Calendar
Asked by
Sean
Top achievements
Rank 1
Answers by
Missing User
Share this question
or