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

Can't Sort Days Order of Appoinments in Monthview

1 Answer 66 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
Karl
Top achievements
Rank 1
Karl asked on 22 Dec 2012, 09:15 PM
Hello,

I use RadScheduler in my project and my appointments have custom colors, icons etc.
I add appointments to RadScheduler manually in the following way:
foreach (var app in appointments)
    radScheduler1.Appointments.Add(app);

I have a problem with RadScheduler MonthView. I want to add appointments to MonthView and I want them to be shown sorted by time (IEvent.Start.TimeOfDay), so if app1.Start.TimeOfDay > app2.Start.TimeOfDay and app1.Start.Date == app2.Start.Date then app1 should appear under app2.

I tried to solve this problem by ordering my appointments collection:
var appointments = src.OrderBy(a => a.Start.TimeOfDay);
foreach (var app in appointments)
    radScheduler1.Appointments.Add(app);

But this did not help, so is there a way to solve this problem? Actually I need a way for sorting appointments by time in MonthView.

I am sending you an image of the MonthView, where you can see that appointments are ordered in an inccorrect way. Take a look at Dec 20 and you will see the appointment, that appears at the bottom has its Start.TimeOfDay 09:15, so it should appear as the second starting from the top. Why does it behave in such a strange way?

Thank you for your support.

Karl

1 Answer, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 26 Dec 2012, 01:20 PM
Hello Karl,

Thank you for writing.

I have tested the described approach and I did not find any issues with the order of the added appointments. The RadShceduler control always sorts the appointments using the start DateTime. Here is a used test application:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Telerik.WinControls.UI;
 
namespace Lab.Scheduler
{
    public partial class SchedulerSortAppointmentsForm : Form
    {
        private RadScheduler scheduler = new RadScheduler();
 
        public SchedulerSortAppointmentsForm()
        {
            InitializeComponent();
 
            scheduler.Dock = DockStyle.Fill;
            scheduler.Parent = this;
            scheduler.ActiveViewType = SchedulerViewType.Month;
        }
 
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
 
            
            Appointment apt = new Appointment(DateTime.Now.AddHours(1), new TimeSpan(1, 0, 0), "Appointment 2");
            scheduler.Appointments.Add(apt);
 
            apt = new Appointment(DateTime.Now, new TimeSpan(1, 0, 0), "Appointment 1");
            scheduler.Appointments.Add(apt);
 
            apt = new Appointment(DateTime.Now.AddMinutes(70), new TimeSpan(1, 0, 0), "Appointment 3");
            scheduler.Appointments.Add(apt);
        }
    }
}

Please view the result in the attached screenshot. If you continue to experience the same issue please send us a small part of your data and sample project to investigate the case locally.

Thank you for your time and cooperation.

All the best,
Julian Benkov
the Telerik team
Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
Tags
Scheduler and Reminder
Asked by
Karl
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Share this question
or