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

Generate TimeSlot in TimeView as per WeekDay

5 Answers 52 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Ronak
Top achievements
Rank 1
Ronak asked on 25 Jul 2011, 06:29 PM
Hello Telerik Team,
I am using RadDateTime Picker Control now i would like render this control based on some Criteria.
first If WeekDay of Selected Date is M-F then generate timeSlot 5:30 PM,8:30 PM in TimePicker
Second if its Saturday then 12:30 P.M. etc and Third if its sunday then some other timeslot.

Last i want to gray out all Past Date from CurrentDate so user cant select past Date

Please advise

Thank
Ronak

5 Answers, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 29 Jul 2011, 07:32 AM
Hello Ronak,

I am afraid that the required functionality is not supported. The problem is that the TimeView component is rendered on the server while its opening is a complete client-side operation. This would require clearing / restoring of the relevant time view cells every time it is opened on the client. You can use the picker's OnPopupOpening client side event for this purpose, but since this functionality is not supported, I can not guarantee you that it will work as expected in different scenarios.

All the best,
Martin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Ronak
Top achievements
Rank 1
answered on 29 Jul 2011, 12:42 PM
Thanks Martin for your reply.
i am able to generate dynamic timeSlots using following piece of code but i want to implement ajax in this if you can help me with that.
please see code below and see its going to work or not

protected void OnSelectedDateChanged(object sender, SelectedDateChangedEventArgs e) {
           if (e.NewDate != null) {
 
               
               DateTime selectedDT = Convert.ToDateTime(e.NewDate);
               List<DateTime> timeSlots = null;
               switch (selectedDT.DayOfWeek) {
                   case DayOfWeek.Monday :
                       timeSlots = new List<DateTime>();
                       timeSlots.Add(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 17, 30, 00));
                       timeSlots.Add(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 20, 00, 00));
                       timeSlots.Add(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 22, 00, 00));
                       break;
                   case DayOfWeek.Tuesday:
                       timeSlots = new List<DateTime>();
                       timeSlots.Add(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 17, 30, 00));
                       timeSlots.Add(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 20, 00, 00));
                       timeSlots.Add(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 22, 00, 00));
                       break;
                   case DayOfWeek.Wednesday:
                       timeSlots = new List<DateTime>();
                       timeSlots.Add(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 17, 30, 00));
                       timeSlots.Add(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 20, 00, 00));
                       timeSlots.Add(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 22, 00, 00));
                       break;
                   case DayOfWeek.Thursday:
                       timeSlots = new List<DateTime>();
                       timeSlots.Add(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 17, 30, 00));
                       timeSlots.Add(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 20, 00, 00));
                       timeSlots.Add(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 22, 00, 00));
                       break;
                   case DayOfWeek.Friday:
                       timeSlots = new List<DateTime>();
                       timeSlots.Add(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 17, 30, 00));
                       timeSlots.Add(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 20, 00, 00));
                       timeSlots.Add(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 22, 00, 00));
                       break;
                   case DayOfWeek.Saturday:
                       timeSlots = new List<DateTime>();
                       timeSlots.Add(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 12, 30, 00));
                       timeSlots.Add(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 15, 00, 00));
                       timeSlots.Add(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 17, 30, 00));
                       timeSlots.Add(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 20, 00, 00));
                       break;
                   case DayOfWeek.Sunday:
                       timeSlots = new List<DateTime>();
                       timeSlots.Add(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 15, 00, 00));
                       timeSlots.Add(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 17, 30, 00));
                       timeSlots.Add(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 20, 00, 00));
                       break;
                  
               }
               RadDateTimePicker1.TimeView.DataList.DataSource = timeSlots;
               RadDateTimePicker1.TimePopupButton.Visible = true;
           }
            
       }

Thanks
Ronak
0
Martin
Telerik team
answered on 29 Jul 2011, 04:11 PM
Hello Ronak,

I am not quite sure that I understand your question. If you would like to make AJAX request instead of postback on every selection then you can AJAX-ify your picker. You can use our AJAX controls or standard UpdatePanel controls. You will have to set the AutoPostBackControl property accordingly:

<telerik:RadDateTimePicker runat="server" ID="RadDateTimePicker1" AutoPostBackControl="Calendar" OnSelectedDateChanged="OnSelectedDateChanged">
</telerik:RadDateTimePicker>

I hope this helps.

Greetings,
Martin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Ronak
Top achievements
Rank 1
answered on 29 Jul 2011, 04:19 PM
Thanks
Thats what exactly i am doing but still not able to make it work anyway i will try it again send u error.

Thanks
Ronak
0
Tsvetina
Telerik team
answered on 04 Aug 2011, 09:59 AM
Hi Ronak,

You should better also paste your ajaxifying logic - what AJAX controls do you use and how is the RadDateTimePicker  ajaxified by them. Also, you mentioned an error, what exactly is it?

Generally, AJAX has no influence on the control logic and behavior, it refreshes the client state of the ajaxified object using the response returned from the server. So if the code works without AJAX, it will work with AJAX as well.

Best wishes,
Tsvetina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Calendar
Asked by
Ronak
Top achievements
Rank 1
Answers by
Martin
Telerik team
Ronak
Top achievements
Rank 1
Tsvetina
Telerik team
Share this question
or