Thanks for sharing your sample.
When appointments are rendered using URL binding, appointments can’t be retrieved in Create event. We have modified your sample to apply red color only for the overlapped div as shown in the below image and kindly download the sample from the below link.
Kindly refer the below code example used in the sample.
<Code>
function onCreate() { // this function will be called on initial load
dataManager2 = ej.DataManager({
url: '@Url.Action("GetProjectsData", "Projects")',
crossDomain: true
});
dataManager2.adaptor = new ej.UrlAdaptor();
var ds = dataManager2.executeQuery(new ej.Query());
ds.done(function (e) {
grupColor();
});
}
function grupColor() { // this function will be called on initial load and action complete event
var obj = $("#ProjectsSchedule").ejSchedule("instance");
for (var ii = 0, res = obj._tempResource[0].resourceSettings.dataSource; ii < res.length; ii++) {
var currentViewAppointments = appointmentCount(), filterData = [];
var appointments = new ej.DataManager(currentViewAppointments).executeLocal(new ej.Query().where("RoomId", ej.FilterOperators.equal, obj._tempResource[0].resourceSettings.dataSource[ii].id));
for (var i = 0, len = appointments.length; i < len; i++) {
var record = appointments[i];
var predicate1 = ej.Predicate(obj._appointmentSettings["startTime"], ej.FilterOperators.greaterThanOrEqual, new Date(record[obj._appointmentSettings["startTime"]])).and(obj._appointmentSettings["endTime"], ej.FilterOperators.lessThanOrEqual, new Date(record[obj._appointmentSettings["endTime"]]));
var predicate2 = ej.Predicate(obj._appointmentSettings["endTime"], ej.FilterOperators.greaterThanOrEqual, new Date(record[obj._appointmentSettings["startTime"]])).and(obj._appointmentSettings["startTime"], ej.FilterOperators.lessThanOrEqual, new Date(record[obj._appointmentSettings["endTime"]]));
var predicate = predicate1.or(predicate2);
var filterData = new ej.DataManager(appointments).executeLocal(new ej.Query().where(predicate));
if (filterData.length > 1) {
var proxy = obj, days = [];
filterData.forEach(function (objj) {
days.push({ Guid: objj["Guid"], duration: Math.round((objj["EndTime"].getTime() - objj["StartTime"].getTime()) / (1000 * 60 * 60)) });
});
min = days[0].duration;
for (var i = 1; i < days.length; i++)
min = Math.min(days[i].duration, min);
var minObj = new ej.DataManager(days).executeLocal(new ej.Query().where("duration", ej.FilterOperators.equal, min));
obj.element.find(".e-categorybar").filter("div[id=categorybar_" + minObj[0]["Guid"] + "]").css({ background: "red" });
}
}
}
}
function appointmentCount() {
var obj = $("#ProjectsSchedule").ejSchedule("instance");
var renderDate = (obj.model.orientation == "horizontal" && (obj.currentView() == "month" || obj._isCustomMonthView())) ? obj.monthDays : obj._dateRender,
appointments = obj._appointmentSort(obj._processed),
startDate = obj.currentView() == "agenda" ? new Date(new Date(obj.currentDate()).setHours(0, 0, 0)) : new Date(renderDate[0]),
endDate = obj.currentView() == "agenda" ? new Date(new Date(new Date(obj.currentDate()).setDate(startDate.getDate() + (obj.model.agendaViewSettings.daysInAgenda > 0 ? obj.model.agendaViewSettings.daysInAgenda - 1 : 0))).setHours(23, 59, 59)) : new Date(new Date(renderDate[renderDate.length - 1]).setHours(23, 59, 59)),
predicate = ej.Predicate(obj._appointmentSettings["startTime"], ej.FilterOperators.greaterThanOrEqual, startDate).and(obj._appointmentSettings["startTime"], ej.FilterOperators.lessThanOrEqual, endDate),
newAppList = new ej.DataManager(appointments).executeLocal(new ej.Query().where(predicate));
return newAppList;
}
</Code>
Regards,
Karthigeyan