Generate TimeSlot in TimeView as per WeekDay

6 posts, 0 answers
  1. Ronak
    Ronak avatar
    108 posts
    Member since:
    Sep 2010

    Posted 25 Jul 2011 Link to this post

    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
  2. Martin
    Admin
    Martin avatar
    833 posts

    Posted 29 Jul 2011 Link to this post

    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.

  3. Ronak
    Ronak avatar
    108 posts
    Member since:
    Sep 2010

    Posted 29 Jul 2011 Link to this post

    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
  4. Martin
    Admin
    Martin avatar
    833 posts

    Posted 29 Jul 2011 Link to this post

    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.

  5. Ronak
    Ronak avatar
    108 posts
    Member since:
    Sep 2010

    Posted 29 Jul 2011 Link to this post

    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
  6. Tsvetina
    Admin
    Tsvetina avatar
    2481 posts

    Posted 04 Aug 2011 Link to this post

    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.

Back to Top