Cannot read property 'getHours' of undefined

2 posts, 0 answers
  1. Brad
    Brad avatar
    19 posts
    Member since:
    Jun 2016

    Posted 14 Aug 2017 Link to this post

    getting the error in the title when i try to view any 'view' of the scheduler other than 'month'.  Below is my scheduler code:

    @using Kendo.Mvc.UI;
    <div>
        @(Html.Kendo().Scheduler<CoBRAMVC4Portal.Areas.Admin.Models.ExerciseCalendarModel>()
        .Name("exSched")
        .Date(System.DateTime.UtcNow.Date)
        .Views(views =>
        {
            views.DayView();
            views.WorkWeekView();
            views.WeekView();
            views.MonthView(monthView => monthView.Selected(true));
        })
        .Timezone("Etc/UTC")
        .Editable(false)
        .Group(group => { group.Resources("ExerciseGUID"); group.Date(true); })
        .DataSource(d => d
            .Model(m =>
            {
                m.Id(f => f.ProjectGUID);
                m.Field(f => f.ExerciseLevelGUIDs);
                m.Field(f => f.IncidentCategoryGUIDs);
            })
            .Read(read => read.Action("_GetExerciseListCalendarAsDates", "Exercise", new { area = "Admin", id = ViewContext.RouteData.Values["id"] }).Type(HttpVerbs.Get))
            )
            .Events(e =>
            {
                e.DataBound("scheduler_dataBound");
                e.DataBinding("scheduler_dataBinding");
            })
            .EventTemplate("<div class='media' style='margin:0px;'>" +
                        "<div class='media-body' style='padding:5px 0 0;margin:0px;'><h5 title='#=title#' style='padding:0 8px 5px;margin:0px;' class='media-heading'>#= title #</h5></div>" +
                        "<div class='media-right'><a class='btn btn-default btn-xs' title='" + CoBRALocalization.MVC.RootResource.OpenLink + "' href='" + Url.Action("ExerciseView", "Exercise", new { area = "Admin" }, Request.Url.Scheme) + "?StaticGUID=#=StaticGUID#' >" +
                        "<span class='fa fa-folder-open'></span></a></div>" +
        "</div>")
        )
    </div>
    <script>
        function scheduler_dataBound(e) {
        }

        function scheduler_dataBinding(e) {
            //Handle the dataBinding event.
        }
    </script>

    everything works fine in the month view

  2. Dimitar
    Admin
    Dimitar avatar
    807 posts

    Posted 16 Aug 2017 Link to this post

    Hello Brad,

    From the provided configuration I cannot see any resources definition. Group.resources should be defined when grouping by date:
    .Group(group => { group.Resources("Owners"); group.Date(true); })
    .Resources(resource =>
    {
    resource.Add(m => m.OwnerID)
     .Title("Owner")
     .Name("Owners")
     .DataTextField("Text")
     .DataValueField("Value")
     .DataColorField("Color")
     .DataSource(source =>
     {
           source.Read(read =>
      {
      read.Action("GetSections", "Calendar");
      });
    });
    })

    I am also attaching a sample MVC application for your reference, where the above is demonstrated.

    Regards,
    Dimitar
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top