Can not disable/enable raddatepicker!

7 posts, 1 answers
  1. Elton
    Elton avatar
    98 posts
    Member since:
    Oct 2007

    Posted 13 May 2008 Link to this post

    Hello Telerik,

    I m using something from documents to enable/diable a RadDatePicker.

    function disableDateTimePicker()  
    {  
      var picker = $find("<%= RadDateTimePicker1.ClientID %>");         
      picker.get_dateInput().disable();  
      $removeHandler(picker.get_popupButton(), "click", picker._onPopupButtonClickDelegate);  
       
      $removeHandler(picker.get__timePopupImage(), "click", picker._onTimePopupImageClickDelegate);    
    }  
    function enableDateTimePicker()  
    {  
     var picker = $find("<%= RadDateTimePicker1.ClientID %>");         
     picker.get_dateInput().enable();  
     $addHandler(picker.get_popupButton(), "click", picker._onPopupButtonClickDelegate);  
     $addHandler(picker.get__timePopupImage(), "click", picker._onTimePopupImageClickDelegate);     

    the errors I get are:
    1. ._onPopupButtonClickDelegate is null;
    2.get__timePopupImage() is not a valid property. ( for this one I found get_popupImage() is the correct one)
    3. ._onTimePopupImageClickDelegate is null

    Can you please check it.

    Regards,
    Elton
  2. Elton
    Elton avatar
    98 posts
    Member since:
    Oct 2007

    Posted 15 May 2008 Link to this post

    come on guys,

    I think this should be some bug or typo on telerik docs. Any one else run into this before?

  3. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 19 May 2008 Link to this post

    Hello Elton,

    Indeed it seems there are some changes to the event handler disposal logic between the two versions. Here is the modified snippet that works with the latest release:
    <script language=javascript type="text/javascript"
     function pageLoad()   
        {   
             timepicker = $find("<%= RadDateTimePicker1.ClientID %>");  
             imageClickDelegate = timepicker._onTimePopupImageClickDelegate;  
        }  
     function disable()   
        {   
            timepicker.get_dateInput().disable();   
            $removeHandler(timepicker.get__timePopupImage(), "click", timepicker._onTimePopupImageClickDelegate);  
            timepicker._onTimePopupImageClickDelegate = null;  
        }   
      
        function enable()   
        {   
            timepicker.get_dateInput().enable();   
            $addHandler(timepicker.get__timePopupImage(), "click", imageClickDelegate);  
            timepicker._onTimePopupImageClickDelegate = imageClickDelegate;  
        }  
    </script> 
    <body> 
        <form id="form1" runat="server"
            <asp:ScriptManager ID="ScriptManager1" runat="server" /> 
            <div> 
                <telerik:RadDateTimePicker ID="RadDateTimePicker1" runat="server"
                </telerik:RadDateTimePicker> 
             <href="#" onclick="enable();">enable</a>  
             <href="#" onclick="disable();">disable</a>  
             </div> 
        </form> 
    </body> 

    I hope this helps.

    Best wishes,
    Maria Ilieva
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  4. Elton
    Elton avatar
    98 posts
    Member since:
    Oct 2007

    Posted 19 May 2008 Link to this post

    Hi Maria ,
    I tried your code, and unfortunately it doesn't work for me.

    I noticed you are using DateTimePicker and I m using DatePicker.

    After some investigation, I found this code would work for me:
    function disableDateTimePicker(picker)  
            {                   
                  if(picker.get_dateInput().get_enabled() == true)  
                  {         
                      picker.get_dateInput().disable();  
     
                        $removeHandler(picker.get_popupButton(), "click", picker._onPopupButtonClickDelegate);  
           
                  }  
            }  
     
            function enableDateTimePicker(picker)  
            {           
                if(picker.get_dateInput().get_enabled() == false)  
                {  
                     picker.get_dateInput().enable();  
                       
                      $addHandler(picker.get_popupButton(), "click", picker._onPopupButtonClickDelegate);   
                }  
            } 
    I enable and disable the popup button. And it seems work for me.

    The only problem I have is I need to disable the DatePicker once page load. And let the enable/disable function are still working for me.

    I tried to set the 'Enable' property of DatePicker and the DatePopupButton to false, but when I try to call the enable function above, the "picker._onPopupButtonClickDelegate" is null.

    Any idea on this issue?

    Cheers,
    Elton


  5. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 20 May 2008 Link to this post

    Hi Elton,

     You can use the following approach, which is working correctly:

    function pageLoad()    
        {    picker = $find("<%= RadDatePicker1.ClientID %>"); 
             picker.get_dateInput().disable();   
             $removeHandler(picker.get_popupButton(), "click", picker._onPopupButtonClickDelegate); 
             imageClickDelegate = picker._onTimePopupImageClickDelegate;   
        }   
     
       
    function disableDateTimePicker(picker) 
       
            {                    
                  if(picker.get_dateInput().get_enabled() == true)   
                  {          
                      picker.get_dateInput().disable();   
      
                        $removeHandler(picker.get_popupButton(), "click", picker._onPopupButtonClickDelegate);   
            
                  }   
            }   
      
            function enableDateTimePicker(picker) 
                
            {            
                if(picker.get_dateInput().get_enabled() == false)   
                {   
                     picker.get_dateInput().enable();   
                        
                      $addHandler(picker.get_popupButton(), "click", picker._onPopupButtonClickDelegate);    
                }   
            }  

    Let us know if this helps.

    Kind regards,
    Maria Ilieva
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. Elton
    Elton avatar
    98 posts
    Member since:
    Oct 2007

    Posted 20 May 2008 Link to this post

    Thanx Maria ,

    It works.

    The doubt I still have is  before I was using window.onload instead of pageLoad(). And in window.onload I can not use $find() (I always get null). I can only use $get().

    some idea on this?
    80)
  7. Answer
    Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 22 May 2008 Link to this post

    Hello Elton,

    The difference between $find and $get is that $find gets the client-side object of the control according to the new convections of MS AJAX. The function $get is accessing the DOM element of the control and is shorted form document.getElementById(). You can read more on the topic in this post.

    All the best,
    Maria Ilieva
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top