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

Weekend Slots

1 Answer 58 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Robi
Top achievements
Rank 2
Robi asked on 19 Sep 2013, 02:22 PM

Hi,

i want that i can create appointments  which are 3 or 4 weeks long..
Is it possible to ignore the Weekends which are between the appointment? Or can they be made readonly or something else.. when i set IsReadOnly = true   i can max use 5 days (mo - fr) for an appointment  because saturday and sunday are blocked.. 

private void CreateWeekendBlockedDates()
{
    var weekEnds = new List<DateTime>(); //new list with Weekends
    DateTime startDate;
    if (DateTime.Today.DayOfWeek == DayOfWeek.Saturday) //today = saturday?
    {
        startDate = DateTime.Today;
    }
    else
    {
        var diffDay = DateTime.Today.DayOfWeek - DayOfWeek.Saturday;
        startDate = DateTime.Today.AddDays(-diffDay);
    }
    //takes all weekends in 70 days past and 10 years future
    for (var dt = startDate.AddDays(-70); dt < startDate.AddYears(10); dt = dt.AddDays(7))
    {
        weekEnds.Add(dt);
    }
 
    foreach (var weekEnd in weekEnds)
    {
        SpecialSlots.Add(new DaySlot(weekEnd, weekEnd.AddDays(2))
        {
            Description = "",
            IsReadOnly = true  //other possibilities?
        });
    }
}

Regards

1 Answer, 1 is accepted

Sort by
0
Kalin
Telerik team
answered on 24 Sep 2013, 08:30 AM
Hi Robi,

As a solution I can suggest you to use regular Slots instead of ReadOnly, this way you will be able to create longer appointments. As for the weekends you could easily disable the EditAppointmentDialog when user clicks inside them, you will need to handle the the ShowDialog event of the ScheduleView and to show the dialog only when the day is not in the weekend. Please check the code snippet below:

private void scheduleView_ShowDialog(object sender, ShowDialogEventArgs e)
{
    var selectedSlot = (sender as RadScheduleView).SelectedSlot;
    if (this.scheduleView.SpecialSlotsSource.Any(slot => (slot.Start<=selectedSlot.Start && slot.End >= selectedSlot.End)))
    {
        e.Cancel = true;
    }           
}

Hope this will help you.

Regards,
Kalin
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
ScheduleView
Asked by
Robi
Top achievements
Rank 2
Answers by
Kalin
Telerik team
Share this question
or