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

Hide Date portion of Input when Date popup is invisible

2 Answers 87 Views
Input
This is a migrated thread and some comments may be shown as answers.
Lucas Harron
Top achievements
Rank 1
Lucas Harron asked on 09 Feb 2010, 04:14 PM
I'm using a RadDateTimePicker control and in my app the user can configure whether to allow Date and Time, Date only or Time only. I am able to set the Date popup and Time popup as hidden when needed, but I can't figure out how to hide the Date or Time in the input portion of the control. Is this possible, or do I need to use 3 controls to achieve this (DateTimePicker, DatePicker and TimePicker)?

Thanks,
Lucas

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 10 Feb 2010, 06:51 AM
Hello Lucas,

You can set the DateFormat and DisplayDateFormat according to your need in the OnPopupClosing client side event. Here is the example.

Client Side code:
 
    function OnPopupClosing(sender, args) { 
        var datetimePicker = sender; 
        if (condition) { // Here check for the condition 
            // show Date part only 
            datetimePicker.get_dateInput().set_displayDateFormat("MM/dd/yyyy"); 
            datetimePicker.get_dateInput().set_dateFormat("MM/dd/yyyy"); 
        } 
        else { 
            // show Time part only     
            datetimePicker.get_dateInput().set_displayDateFormat("hh:mm:ss"); 
            datetimePicker.get_dateInput().set_dateFormat("hh:mm:ss"); 
        } 
        datetimePicker.get_dateInput().focus(); 
    } 

-Shinu.
0
Lucas Harron
Top achievements
Rank 1
answered on 10 Feb 2010, 04:01 PM
Great, Thanks!

One last question, are you aware of a way to get the browsers short date/ time format so that I can use that instead of hard-coding it?
Tags
Input
Asked by
Lucas Harron
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Lucas Harron
Top achievements
Rank 1
Share this question
or