Thanks for your update.
When two or more appointments are created with the same duration, appointments are internally sorted based on the Start Time, End Time and Guid, since Guid is unique and random, same duration appointments will render in random manner. We have overridden the appointment sorting function on sample side where the appointments are initially sorted based on Start Time, End Time, Guid and then we have returned the sorted appointments based on the Status field value. Therefore, the Pending appointments will be rendered first followed by Approved in the scheduler. Kindly refer the following code example that we have used in the sample.
<Code>
ej.Schedule.prototype._appointmentSort = function (appointments) {
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.Guid.localeCompare(b.Guid);
else if (date1 - date2 == 0)
return d2 - d1 || d3 - d4 || a.Guid.localeCompare(b.Guid);
else
return d3 - d4 || a.Guid.localeCompare(b.Guid);
});
}
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.Guid.localeCompare(b.Guid);
});
}
var Pending = new ej.DataManager(appointments).executeLocal(new ej.Query().where("Status", ej.FilterOperators.equal, "Pending"));
var Approved = new ej.DataManager(appointments).executeLocal(new ej.Query().where("Status", ej.FilterOperators.equal, "Approved"));
var empty = new ej.DataManager(appointments).executeLocal(new ej.Query().where("Status", ej.FilterOperators.equal, ""));
var appointments = [];
$.merge(appointments, Pending);
$.merge(appointments, Approved);
$.merge(appointments, empty);
return appointments;
}
</Code>
Regards,
Karthigeyan