We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

appointment placement

On a schedule without timescale, is there any way to force the system to place the items in a particular order? 

I can hand the schedule an array in the order I would like it displayed on the calendar but the system does not seem to pay any attention to the order I give it. I don't know if there is an option or a setting that allows me to control the order they are placed so that I can place them in alphabetical or some other order based on a given value or set.

For example if you have two items that have the same date/time for the same resource, each time you refresh the calendar they can flip flop with each other so that there is no given way to organize them on the page. This is especially hard for when appointments span over the weekend and you switch the page and now they are no longer in the same order and it makes it hard to follow.

Any help would be appreciated 

1 Reply

KK Karthigeyan Krishnamurthi Syncfusion Team July 17, 2017 09:23 AM UTC

Hi David, 
 
Thank you for contacting Syncfusion support. 
 
When two or more appointments are created with the same duration, the appointments are sorted based on the appointment’s Guid internally before rendering, since Guid of the appointments are unique and random, appointments will be sorted randomly which is the cause for the issue. We have prepared the sample to sort the same duration appointments based on its Subject which can be viewed from the below link. 
 
<Code> 
ej.Schedule.prototype._appointmentSort = function (appointments) { // here internal sorting function is overridden 
    var proxy = this; 
    if (this.currentView() == "agenda") { 
        appointments.sort(function (a, b) { 
            var d1 = a[proxy._appointmentSettings["startTime"]]; 
            var d2 = b[proxy._appointmentSettings["startTime"]]; 
            var d3 = a[proxy._appointmentSettings["endTime"]]; 
            var d4 = b[proxy._appointmentSettings["endTime"]]; 
            return d1.getTime() - d2.getTime() || d3.getTime() - d4.getTime(); 
        }); 
    } 
    else if (this.currentView() != "day") { 
        appointments.sort(function (a, b) { 
            var d1 = a[proxy._appointmentSettings["endTime"]] - a[proxy._appointmentSettings["startTime"]]; 
            var d2 = b[proxy._appointmentSettings["endTime"]] - b[proxy._appointmentSettings["startTime"]]; 
            var date1 = new Date(a[proxy._appointmentSettings["startTime"]]); 
            var date2 = new Date(b[proxy._appointmentSettings["startTime"]]); 
            var date3 = new Date(a[proxy._appointmentSettings["endTime"]]); 
            var date4 = new Date(b[proxy._appointmentSettings["endTime"]]); 
            var d3 = a[proxy._appointmentSettings["startTime"]]; 
            var d4 = b[proxy._appointmentSettings["startTime"]]; 
            if (date1 == date2 && date3 == date4) 
                return d3 - d4 || a.Subject.localeCompare(b.Subject); 
            else if (date1 - date2 == 0) 
                return d2 - d1 || d3 - d4 || a.Subject.localeCompare(b.Subject); 
            else 
                return d3 - d4 || a.Subject.localeCompare(b.Subject); 
        }); 
    } 
    else { 
        appointments.sort(function (a, b) { 
            var d3 = a[proxy._appointmentSettings["startTime"]]; 
            var d4 = b[proxy._appointmentSettings["startTime"]]; 
            var d1 = a[proxy._appointmentSettings["endTime"]] - a[proxy._appointmentSettings["startTime"]]; 
            var d2 = b[proxy._appointmentSettings["endTime"]] - b[proxy._appointmentSettings["startTime"]]; 
            return d3 - d4 || d2 - d1 || a.Subject.localeCompare(b.Subject); 
        }); 
    } 
    return appointments; 
} 
</Code> 
 
Regards, 
Karthigeyan 
 
 



Loader.
Live Chat Icon For mobile
Up arrow icon