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

RadDatePicker OnDateSelected e.get_newDate() doesn't work

6 Answers 273 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Rory
Top achievements
Rank 1
Rory asked on 04 Mar 2008, 10:15 PM
Hi there, title says it all I'm calling the OnDateSelected(sender,e) and trying to use the e.get_newDate() just like your demo and it doesn't return anything. I need to get the date selected or being selected is there something I'm missing? Thanks.

6 Answers, 1 is accepted

Sort by
0
Rory
Top achievements
Rank 1
answered on 04 Mar 2008, 10:28 PM
Ok a little update I got it working by putting the function call in the attributes for <RadDatePicker> rather than the <ClientEvents>. I am now using this function and it works to get the correct selected date. Why does this function work correctly but if you call it from the <clientEvents> it returns the old date?

function OnDateSelected(sender, e)
{
var datePicker = $find("<%= sdpDueDate.ClientID %>");
var date = datePicker.get_selectedDate();
}

<telerik:RadDatePicker ID="sdpDueDate" runat="server" ClientEvents-OnDateSelected="OnDateSelected">  
<Calendar runat="server" OnDayRender="Calendar_OnDayRender"   
     <ClientEvents OnDayRender="OnDayRender" /> 
</Calendar> 
</telerik:RadDatePicker> 
                     

0
Accepted
Giuseppe
Telerik team
answered on 06 Mar 2008, 09:37 AM
Hello Rory,

Are you sure you specified the OnDateSelected handler in the RadDatePicker.ClientEvents section and not in the RadDatePicker.RadCalendar.ClientEvents like this:

<script type="text/javascript"
function OnDateSelected(sender, e) 
    var datePicker = $find("<%= sdpDueDate.ClientID %>"); 
    var date = datePicker.get_selectedDate(); 
</script> 
 
<telerik:RadDatePicker ID="sdpDueDate" runat="server"
    <ClientEvents OnDateSelected="OnDateSelected" /> 
    <Calendar ID="Calendar1" runat="server"
        <ClientEvents /> 
    </Calendar> 
</telerik:RadDatePicker> 


Hope this helps.


Regards,
Manuel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Rory
Top achievements
Rank 1
answered on 06 Mar 2008, 04:57 PM
Yes you are right. I specified <clientevents> inside the <calendar>. Thanks for clarifying.
0
Quim
Top achievements
Rank 1
answered on 23 Sep 2008, 03:44 PM
Hi

I spent some time to find this solution. I think this should be better covered in the manual. There are not to much about RadDatePicker.

Regards
0
Afroz
Top achievements
Rank 1
answered on 16 Mar 2011, 02:39 PM
Hi Team,
i have a problem ,i am using Telerik Date picker and to show current Date i am using below function on

OnPopupOpening Client Event

but the problem is ,i am not able to select Date on a single Click

 

function CurrentDateSelection(sender, eventArgs) {

 

 

 

if (sender.get_selectedDate() == null) {

 

 

eventArgs.set_cancelCalendarSynchronization(

true);

 

 

 

var popup = eventArgs.get_popupControl();

 

 

 

var todaysDate = new Date();

 

 

 

var todayTriplet = [todaysDate.getFullYear(), todaysDate.getMonth() + 1, todaysDate.getDate()];

 

 

popup.selectDate(todayTriplet,

true);

 

 

 

//popup.set_selectedDate(todayTriplet);

 

popup.Selection._enableMultiSelect =

false;

 

 

}

 

}

Can you help me to out this problem or there is also a Onclick event, is it possible to perform any operation to resolve this issue.

Thanks
Afroz

0
Rory
Top achievements
Rank 1
answered on 16 Mar 2011, 05:00 PM
Hi Afroz,
What is your function trying to accomplish? Are you trying to autopopulate the datepicker's textbox with today's date if selected date is null? Or are you just trying to show your users Today's date and then allow them to click it? If you just want them to see what is today's date try using the Special Days with a CssClass.
<telerik:RadDatePicker Runat="server"
    <Calendar runat="server"
        <SpecialDays>
            <telerik:RadCalendarDay repeatable="Today" Date="" 
                 ItemStyle-CssClass="dateToday" />
        </SpecialDays>
    </Calendar>
</telerik:RadDatePicker>

Add this to your CSS File 

/* RadCalendar Custom Today Style */
.dateToday a
{
    color:Blue !important;
}
Tags
Calendar
Asked by
Rory
Top achievements
Rank 1
Answers by
Rory
Top achievements
Rank 1
Giuseppe
Telerik team
Quim
Top achievements
Rank 1
Afroz
Top achievements
Rank 1
Share this question
or