|
var weeknum = 0, count = 0;
var nextRow = true, news, app, start, end, App, endDate;
function OnCheckInfo(args) {
if (args.model.currentView == "agenda" && args.requestType == "agendacells") {
if (args.requestType == "agendacells" && args.cellType == "agendatimecell") {
news = _getWeekno(args.appointment.StartTime);
if (weeknum != news) {
app = this._currentViewAppointments;
start = args.appointment.StartTime;
end = new Date(endDate.setHours(23, 59, 59));
var predicate = ej.Predicate(this._appointmentSettings["startTime"], ej.FilterOperators.greaterThanOrEqual, start).and(this._appointmentSettings["startTime"], ej.FilterOperators.lessThanOrEqual, end);
App = new ej.DataManager(this._currentViewAppointments).executeLocal(new ej.Query().where(predicate));
nextRow = (args.appointment.StartTime.getDate() > end.getDate()) ? true : false;
}
if ((weeknum != news) || count == 0) {
var customDesign = "<td class='e-agendacells datecolumn' rowspan=" + App.length + "><div class='e-textwrapper'><span> Week No:" + news + "</span></div></td>";
$(args.element).before(customDesign); // to add custom column data.
weeknum = news;
count++;
}
}
if (args.requestType == "agendacells" && args.cellType == "agendaheadercells" && $(args.element).hasClass("e-timecolumn") && $(".e-headercells.datecolumn").length == 0) {
var customDesign1 = "<td class='e-headercells datecolumn'><div class='e-textwrapper'><b>Week</b></div></td>";
args.element.before(customDesign1); // to add custom column heading
}
}
}
function OnNavigation(args) {
weeknum = 0, count = 0, nextRow = true;
}
function _getWeekno(date1) {
var date = new Date(date1);
var obj = $("#Schedule1").data("ejSchedule");
var weekFirst = new Date(date.getFullYear(), date.getMonth(), date.getDate());
for (var a = 0, len = obj._dateRender.length / 7 ; a < len; a++) {
var weekDate = weekFirst._currentWeekDates(obj._firstdayofweek);
endDate = weekDate.end; // to get the end date of the week
var weekNo = Math.ceil((((weekDate.start - new Date(weekDate.start.getFullYear(), 0, 1)) / 86400000) + new Date(weekDate.start.getFullYear(), 0, 1).getDay() + 1) / 7);
var weekNumber = (weekNo > 52) ? weekNo - 52 : weekNo;
}
return weekNumber;
} |