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

Disbale DatePicker Disable SharedCalender too

3 Answers 71 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Rory
Top achievements
Rank 1
Rory asked on 07 Oct 2009, 12:36 AM
Hi i'm using this code.

function disable()  
{  
   var picker = $find("<%= RadDatePicker1.ClientID %>");  
   picker.set_enabled(false);  
}  
function enable()  
{  
   var picker = $find("<%= RadDatePicker1.ClientID %>");         
   picker.set_enabled(true);  
}     

It disables the RadDatePicker but it also breaks the SharedCalendar that the DatePicker is using. Which means all other DatePickers on the page stop working correctly. Please Advise.
Thanks.

3 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 09 Oct 2009, 09:15 AM
Hello Rory,

indeed this is expected because by default when you disable an entire date picker, you disable the input, popup button and its popup calendar. Hence when you share single calendar among several date picker controls and disable one of them in this way, the calendar will be disable for all.

To avoid that you need to disable the date input and popup button only as demonstrated in the forthcoming example:

          <script type="text/javascript">  

            function DisableFirstPicker()  

            {  

              var firstPicker = $find("<%=RadDatePicker1.ClientID %>");  

              firstPicker.get_textBox().disabled = "disabled";  

              firstPicker.get_popupButton().disabled = "disabled";  

            }  

          </script> 

            <asp:ScriptManager ID="ScriptManager1" runat="server" /> 

            <telerik:RadDatePicker ID="RadDatePicker1" runat="server" SharedCalendarID="RadCalendar1" /> 

            <telerik:RadDatePicker ID="RadDatePicker2" runat="server" SharedCalendarID="RadCalendar1" /> 

            <telerik:RadDatePicker ID="RadDatePicker3" runat="server" SharedCalendarID="RadCalendar1" /> 

            <br /> 

            <input type="button" value="Disable first picker" onclick="DisableFirstPicker()" /> 

            <telerik:RadCalendar ID="RadCalendar1" runat="server" /> 


Best regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Tom Jaspering
Top achievements
Rank 1
answered on 10 Apr 2012, 07:32 PM
After upgrading to the latest 2012 build. This functionality of disabling the textbox is leading to javascript errors while clicking the disabled textbox of the datepicker.

This is the error:
"Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus."

Please Advise.
0
Accepted
Tom Jaspering
Top achievements
Rank 1
answered on 11 Apr 2012, 06:31 PM
This works and prevents the javascript error in IE8


var rdp = $find("<%=RadDatePicker1.ClientID %>");  
if(disable)
{
    rdp.get_textBox().readOnly = true;
    rdp.get_textBox().disabled = "disabled"; 
    rdp.get_popupButton().disabled = "disabled";
}
else
{
    rdp.get_textBox().readOnly = false;
    rdp.get_textBox().disabled = "";  
    rdp.get_popupButton().disabled = "";
}
Tags
Calendar
Asked by
Rory
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Tom Jaspering
Top achievements
Rank 1
Share this question
or