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

RadDatePicker:Client side :setting up MaxDate and SeDate after clearing the special Days

1 Answer 342 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Krishna
Top achievements
Rank 1
Krishna asked on 07 Oct 2009, 01:30 AM
Hi,
I have below requirement
on page load I have set the Maxdate of the datepicker to today.. and I have some special days which are added when page load itself.
that was fine..
when i click on one button i need to do some changes to date picker at client side..
The main inportant thing is the Selected date must be today + 10 days ..which i am unable to with below code
        var datpick1 = <%= datpick1.ClientID %>;  
        var datpick2 = <%= datpick2.ClientID %>;  
        var calendar2 = <%= datpick2.ClientID %>.GetCalendar();  
        calendar2.SpecialDays.Clear();  
        calendar2.SetMaxDate(datpick1.GetMaxDate());//datpick1.GetMaxDate() is 10 days greater than datpick2 max date  
        var da = new Date(datpick1.GetMaxDate());  
        da.setDate(da.getDate());  
        calendar2.SetDate(da); 

1. Clear the special Days (working fine)
2.Set the MaxDate() which also seems to be working fine
3.Set the date using SetDate() which seems to be not working (with the max date greater than the max date defined on page load)
if i give SetDate as less than or equal to the Pageload the Maxdate it is working fine.

Please help me to set the date at client side ..
Please let me know if i am missing any thingelse

Thanks
-Krishna

1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 09 Oct 2009, 11:23 AM
Hello Krishna,

First of all, you are referring to the classic RadControls for ASP.NET, while the thread info says you are using RadCalendar for ASP.NET AJAX. I am assuming we are talking about the classic controls.

The javascript you have provided contains some problematic statements, particularly:

1. SetMaxDate()  is a property of the client RadDatePicker object. The respective property for RadCalendar is SetRangeMaxDate()

2. Client RadCalendar object does not have a property names SetDate(). Such a property is provided by RadDatePicker.

I believe you wanted to modify the max date and selected date of RadDatePicker. Now, with RadDatePicker, you are also using a RadDateInput (the textbox that displays the selected date). RadDateInput's client object also has its own MinDate and MaxDate property. When setting the MaxDate property of the picker, the new date is not updated as the MaxDate property of the date input. You need to manually set it:

var picker = window['<%= datpick1.ClientID %>'];
picker.SetMaxDate(new Date("10/20/2009"));
picker.DateInput.MaxDate = picker.GetMaxDate();
picker.SetDate(new Date("10/15/2009"));

The above code works as expected now. Check it out.

Regards,
Veli
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.
Tags
Calendar
Asked by
Krishna
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or