I created a custom view for a work week.
C# class:
public class WorkWeekView : SchedulerView
{
public WorkWeekView() : base()
{
// view type must be equal to the one defined on the client
Name = ViewType = “workweek”;
Label = “Work Week”;
TabWidth = 75;
}
}
Added it to the controller method:
var scheduler = new DHXScheduler
{
Skin = DHXScheduler.Skins.Terrace,
Config =
{
first_hour = 6,
last_hour = 24,
readonly_form = true,
separate_short_events = true,
preserve_scroll = true,
collision_limit = 1000,
cascade_event_count = 1000,
max_month_events=1000
},
LoadData = true,
DataAction = Url.Action(MVC.Calendar.Calendar.Data()),
};
scheduler.EnableDynamicLoading(SchedulerDataLoader.DynamicalLoadingMode.Week);
scheduler.Extensions.Add(SchedulerExtensions.Extension.Multisource);
scheduler.Extensions.Add(SchedulerExtensions.Extension.Expand);
var workWeekView = new WorkWeekView();
scheduler.Views.Add(workWeekView);
if (!string.IsNullOrEmpty(Current.CalendarView))
{
scheduler.InitialView = workWeekView.Name;
}
scheduler.Data.Loader.AddParameter(“emails”, string.Join(";", emails.ToArray()));
added methods to the view:
$(document).ready(function () {
scheduler.date.workweek_start = function(date) {
return scheduler.date.week_start(date);//
}
scheduler.date.add_workweek=function(date,inc){
return scheduler.date.add(date,inc*7,“day”);
}
scheduler.date.get_workweek_end=function(start_date){
return scheduler.date.add(start_date,5,“day”);
}
scheduler.templates.workweek_date = scheduler.templates.week_date;
scheduler.templates.workweek_scale_date = scheduler.templates.week_scale_date;
scheduler.attachEvent(“onTemplatesReady”, function () {
scheduler.date.workweek_start = scheduler.date.week_start;
scheduler.templates.workweek_date = scheduler.templates.week_date;
scheduler.templates.workweek_scale_date = scheduler.templates.week_scale_date;
scheduler.date.add_workweek = function (date, inc) { return scheduler.date.add(date, inc * 7, “day”); }
scheduler.date.get_workweek_end = function (date) { return scheduler.date.add(date, 5, “day”); }
});
});
When ever I try to load the scheduler using the work week view I get this error:
Uncaught TypeError: Cannot read property ‘0’ of undefined
at Object.scheduler.render_view_data (:165:336)
at Object.scheduler.update_view (:103:108)
at Object.scheduler.updateView (:106:97)
at Object.scheduler.setCurrentView (:106:378)
at Object.scheduler.init (:70:340)
at :22:12
at hr (jsForBootstrapLayout?v=Pmpt5ePOaigko8j8eGgjtGdrplxmTiABXFUIyA162h41:1)
at ot (jsForBootstrapLayout?v=Pmpt5ePOaigko8j8eGgjtGdrplxmTiABXFUIyA162h41:1)
at i.fn.init.append (jsForBootstrapLayout?v=Pmpt5ePOaigko8j8eGgjtGdrplxmTiABXFUIyA162h41:1)
at i.fn.init. (jsForBootstrapLayout?v=Pmpt5ePOaigko8j8eGgjtGdrplxmTiABXFUIyA162h41:1)
What am I missing?