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

DatePopupButton

1 Answer 44 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Cush
Top achievements
Rank 1
Cush asked on 12 Nov 2011, 11:55 PM
Hi All

I have a RadDateTime Picker which is enabled / disabled based on the value of a checkbox,
I have just changed the enable disable event from server side to client side, this has caused a problem with the onclick event that i add to the DatePopUpButton on Page Load server side?
Page Load:
  
RadDateTimePicker1.DatePopupButton.Attributes.Add("onclick","Myevent(event, '" + RadDateTimePicker1.ClientID + "');return false;")
  
function Myevent(e, pickerID) {
    var datePicker;
    datePicker = $find(pickerID);
  
    var textBox = datePicker.get_textBox();
    var popupElement = datePicker.get_popupContainer();
  
    var dimensions = datePicker.getElementDimensions(popupElement);
    var position = datePicker.getElementPosition(textBox);
    var popOffset = (dimensions.height - position.y)
                          
    if (popOffset <= 0) {
                          
        datePicker.showPopup(position.x, position.y - dimensions.height);
  
    } else {
                              
        datePicker.showPopup(position.x, position.y - dimensions.height + popOffset);
    }
  
}

The problem is that now when the DatePopupButton is clicked the calendar momentarily appear then disappear??

I have seen another post HERE with a similar problem however i would rathe not use this solution as i want to use the approach that i already have as i have found this more reliable.

Does anybody have any idea why this is happening and how i can cure it please?

Many Thanks

Best Regards

Cush

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 14 Nov 2011, 08:51 AM
Hello ,

You can add togglePopup to the javascript. Here is the sample code.

JS:
<script type="text/javascript">
function Myevent()
     {
       var datePicker;
       datePicker = $find("<%=RadDateTimePicker1.ClientID %>");
       var textBox = datePicker.get_textBox();
       var popupElement = datePicker.get_popupContainer();
       var dimensions = datePicker.getElementDimensions(popupElement);
       var position = datePicker.getElementPosition(textBox);
       var popOffset = (dimensions.height - position.y)
       if (popOffset <= 0)
       {
          datePicker.showPopup(position.x, position.y - dimensions.height);
          datePicker.togglePopup();
      }
      else
       {
          datePicker.showPopup(position.x, position.y - dimensions.height + popOffset);
          datePicker.togglePopup();
       }
    }
</script>

Thanks,
Princy.
Tags
Calendar
Asked by
Cush
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Share this question
or