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

DateTimePicker open above the textbox instead of below

3 Answers 215 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jordan
Top achievements
Rank 1
Jordan asked on 18 Jul 2011, 09:41 PM
I am working within a modal window that nests the content in an iFrame, so when the DateTimePicker calendar opens below the textbox it gets cut off at the iFrame bottom border. The simple quick solution would be to have the calendar open above the textbox, but I have not seen any way of doing this with the MVC DateTimePicker. Is there a way to control the vertical direction that the calendar and time popouts open?

3 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 19 Jul 2011, 08:06 AM
Hi Jordan,

You can use the following script to open the Calendar popup above the picker's textbox:


<%= Html.Telerik().DatePicker().Name("Picker1").ClientEvents(events => events.OnOpen("Picker1_Open")) %>


function Picker1_Open(e)
{
    e.preventDefault();
    e.stopPropagation();
    var picker = $(this).data("tDatePicker");
    var popup = $("body>.t-animation-container");
    var elementPosition = picker.$element.offset();
    var position = [];
    position.outerHeight = picker.$element.outerHeight();
    position.outerWidth = picker.$element.outerWidth();
    position.zIndex = $.telerik.getElementZIndex(picker.$element);
    position.offset = [];
    position.offset.left = elementPosition.left;
    position.offset.top = elementPosition.top - popup.outerWidth() - position.outerHeight;
    picker.dateView.open(position);
}


Regards,
Dimo
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Aleks
Top achievements
Rank 1
answered on 05 Apr 2012, 07:59 AM
You have error in code, there must be popup.outerHeight() instead of popup.outerWidth():

position.offset.top = elementPosition.top - popup.outerHeight() - position.outerHeight;
0
Karim
Top achievements
Rank 1
answered on 14 May 2012, 12:58 PM
Hi, I have the same problem but with TimePicker, i tried the code above with some modification but it didn't work could you please help me.
Tags
Date/Time Pickers
Asked by
Jordan
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Aleks
Top achievements
Rank 1
Karim
Top achievements
Rank 1
Share this question
or