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

RadDateTimePicker - Showing/hiding TimeView

4 Answers 391 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
John Brownell
Top achievements
Rank 1
John Brownell asked on 04 Mar 2008, 08:10 PM
I updated my calendar control to the Prometheus version and it broke some of the funtionality i was previously using. I will describe what I am trying to do and hopefully someone can let me know how I can implement this with the Prometheus controls or if this is in fact a bug.

Previously, I was using a RadDateTimePicker control with a Checkbox control labeled "Enter time". I was setting the visibility of the TimeView part, and the format of the dateview part, using the status of the checkbox ... like this:

bool enterTime = chkShowTimes.Checked;  
 
RadDateTimePicker1.DateInput.DateFormat = enterTime ? "M/d/yyyy h:mm tt" : "d";  
RadDateTimePicker1.DateInput.DisplayDateFormat = enterTime ? "M/d/yyyy h:mm tt" : "d";  
 
RadDateTimePicker1.TimeView.Visible = enterTime;  
RadDateTimePicker1.TimePopupButton.Visible = enterTime;  
 

This concept worked in the non-Prometheus version, but now once I set the "TimeView" portion "visible = false", I get a javascript error:

Microsoft JScript runtime error: Sys.InvalidOperationException:   
Component 'RadDateTimePicker1_timeView' was not found. 

And once this happens, the calendar button breaks and does not popup the calendar.

Any ideas?

Thanks,
John
Pyron Technologies

4 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 07 Mar 2008, 09:31 AM
Hello John,

Hiding the control like this causes it not to render properly, and some of the resources may therefore not be found. Therefore, you can try a different approach to hide the items:

.css
<style type="text/css">  
 
.class1  
{  
display:none;  
}  
 
.class2  
{  
display:block;  
}  
 
</style> 

.cs
 protected void Page_Load(object sender, EventArgs e)  
    {  
        bool enterTime = chkShowTimes.Checked;  
 
        RadDateTimePicker1.DateInput.DateFormat = enterTime ? "M/d/yyyy h:mm tt" : "d";  
        RadDateTimePicker1.DateInput.DisplayDateFormat = enterTime ? "M/d/yyyy h:mm tt" : "d";  
 
        RadDateTimePicker1.TimeView.CssClass = enterTime ? "class1" : "class2";  
        RadDateTimePicker1.TimePopupButton.CssClass = enterTime ? "class1" : "class2";  
    } 

I hope this suggestion helps.

Best wishes,
Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
James
Top achievements
Rank 1
answered on 24 Jul 2013, 03:26 PM
I realize this is an old post but I have a follow-up question.  I'm trying to replace a RadDatePicker control with a RadDateTimePicker control and selectively hide/show the time portion.  I followed Yavor's suggestion above and it works as expected, however, even though the clock icon is not displayed, it displays any selected dates followed by "12:00 AM".  For example, if I choose 7/23/2013 in the calendar popup, it shows "7/23/2013 12:00 AM" in the text area.  Both the DateFormat and DisplayDateFormat values are set to "d" which equates to "M/d/yyyy".  How can I also hide the "12:00 AM" from appearing along with the selected date?

Thank you,

James
0
James
Top achievements
Rank 1
answered on 24 Jul 2013, 03:26 PM
I realize this is an old post but I have a follow-up question.  I'm trying to replace a RadDatePicker control with a RadDateTimePicker control and selectively hide/show the time portion.  I followed Yavor's suggestion above and it works as expected, however, even though the clock icon is not displayed, it displays any selected dates followed by "12:00 AM".  For example, if I choose 7/23/2013 in the calendar popup, it shows "7/23/2013 12:00 AM" in the text area.  Both the DateFormat and DisplayDateFormat values are set to "d" which equates to "M/d/yyyy".  How can I also hide the "12:00 AM" from appearing along with the selected date?

Thank you,

James
0
A2H
Top achievements
Rank 1
answered on 24 Jul 2013, 07:35 PM

Hi James,

A slight modification to the code will do the task here

We are hiding the timeview when check box is checked but at the same time here we are assigning the date format  of  RadDateTimePicker1 as "M/d/yyyy h:mm tt” instead of “d”.

When I change the condition check code its starting working fine.

Please use the below code


bool enterTime = CheckBox1.Checked;
 
        RadDateTimePicker1.DateInput.DateFormat = enterTime ? "d" : "M/d/yyyy h:mm tt";
        RadDateTimePicker1.DateInput.DisplayDateFormat = enterTime ? "d" : "M/d/yyyy h:mm tt";
         
        RadDateTimePicker1.TimeView.CssClass = enterTime ? "class1" : "class2";
        RadDateTimePicker1.TimePopupButton.CssClass = enterTime ? "class1" : "class2";

Thanks,
A2H
Tags
Calendar
Asked by
John Brownell
Top achievements
Rank 1
Answers by
Yavor
Telerik team
James
Top achievements
Rank 1
A2H
Top achievements
Rank 1
Share this question
or