Hide Date portion of Input when Date popup is invisible

3 posts, 0 answers
  1. Lucas Harron
    Lucas Harron avatar
    5 posts
    Member since:
    Oct 2009

    Posted 09 Feb 2010 Link to this post

    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. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 10 Feb 2010 Link to this post

    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.
  3. Lucas Harron
    Lucas Harron avatar
    5 posts
    Member since:
    Oct 2009

    Posted 10 Feb 2010 Link to this post

    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?
Back to Top