Scheduler not showing any events
2 Answers 16 Views
cameron
Top achievements
Rank 1
Iron
cameron asked on 24 May 2021, 08:56 AM

I have been trying to get a scheduler to show simple events, but Im doing some wrong (probably something simple I'm not seeing.

I'm simply trying to return a list into the schedular based on the demo TaskViewModel

 

What am I doing wrong here.

 

Thanbks in advance

@(Html.Kendo().Scheduler<ShitTruckLibrary.Models.TaskViewModel>()
    .Name("scheduler")
    .Date(new DateTime(2021, 05, 10))
    .StartTime(new DateTime(2021, 5, 08, 00, 00, 00))
    .Height(600)
    .Views(views =>
    {
        views.DayView();
        views.WorkWeekView(workWeekView => workWeekView.Selected(true));
        views.WeekView();
        views.MonthView();
   
        views.AgendaView();
        views.TimelineView();
    })
    .Timezone("Etc/UTC")
    .Resources(resource =>
    {
        resource.Add(m => m.OwnerID)
            .Title("Owner")
            .DataTextField("Text")
            .DataValueField("Value")
            .DataColorField("Color")
            .BindTo(new[] {
                new { Text = "STC", Value = 1, Color = "#f8a398" } ,
                new { Text = "GTC", Value = 2, Color = "#51a0ed" }
               
            });
    })
    .DataSource(d => d
        .Model(m => {
            m.Id(f => f.TaskID);
            m.Field(f => f.Title).DefaultValue("No title");
            m.Field(f => f.OwnerID).DefaultValue(1);
            m.RecurrenceId(f => f.RecurrenceID);
        })
        .Read("Basic_Usage_Read", "WorkJobs")
   
        .Filter(filters =>
        {
            filters.Add(model => model.OwnerID).IsEqualTo(1).Or().IsEqualTo(2);
        })
    )
)

 public static  IList<TaskViewModel> GetAllJobs()
        {
            List<ContactJob> c = new List<ContactJob>();

            List<TaskViewModel> caLL = new List<TaskViewModel>();

            DataTable dt = new DataTable();

                    
            dt = SqlStore.CreateDataSet($@"SELECT cj.*,ForeName, SurName, CompanyName,Address1,Address2 FROM [dbo].[ContactJob]  cj join [dbo].[Contacts] c on cj.contactid = c.id order by JobDate desc").Tables[0];

            c = DataHelper.ConvertDataTable<ContactJob>(dt);
        


            foreach (ContactJob cc in c)
            {

                TaskViewModel vv = new TaskViewModel();
                vv.Start = DateTime.SpecifyKind(new DateTime(cc.JobDate.Year, cc.JobDate.Month, cc.JobDate.Day, 09, 00, 00),DateTimeKind.Local);
                vv.End = DateTime.SpecifyKind(new DateTime(cc.JobDate.Year, cc.JobDate.Month, cc.JobDate.Day, 10, 00, 00), DateTimeKind.Local);
                vv.Title = $"{cc.CompanyName} {cc.ForeName} {cc.SurName}".Trim();
                vv.Description = $"{cc.Address1} {cc.Address1}";
                vv.IsAllDay = true;
                vv.OwnerID = (cc.Type == "STC" ? 1 : 2);
                caLL.Add(vv);
            }


            return caLL;
        }

 

 public virtual JsonResult Basic_Usage_Read([DataSourceRequest] DataSourceRequest request)
        {
            return Json(Job.GetAllJobs().ToDataSourceResult(request));
        }

        public static  IList<TaskViewModel> GetAllJobs()
        {
            List<TaskViewModel> caLL = new List<TaskViewModel>();

            DataTable dt = SqlStore.CreateDataSet($@"SELECT cj.*,ForeName, SurName, CompanyName,Address1,Address2 FROM [dbo].[ContactJob]  cj join [dbo].[Contacts] c on cj.contactid = c.id order by JobDate desc").Tables[0];

            List<ContactJob> c = DataHelper.ConvertDataTable<ContactJob>(dt);

            foreach (ContactJob cc in c)
            {

                TaskViewModel vv = new TaskViewModel();
                vv.Start = DateTime.SpecifyKind(new DateTime(cc.JobDate.Year, cc.JobDate.Month, cc.JobDate.Day, 09, 00, 00),DateTimeKind.Local);
                vv.End = DateTime.SpecifyKind(new DateTime(cc.JobDate.Year, cc.JobDate.Month, cc.JobDate.Day, 10, 00, 00), DateTimeKind.Local);
                vv.Title = $"{cc.CompanyName} {cc.ForeName} {cc.SurName}".Trim();
                vv.Description = $"{cc.Address1} {cc.Address1}";
                vv.IsAllDay = true;
                vv.OwnerID = (cc.Type == "STC" ? 1 : 2);
                caLL.Add(vv);
            }


            return caLL;
        }

 

2 Answers, 1 is accepted

Sort by
0
cameron
Top achievements
Rank 1
Iron
answered on 27 May 2021, 06:55 AM

Fixed now,  not sure what I did, I just started again and it worked , so something small i had wrong

 

Thanks

0
Ivan Danchev
Telerik team
answered on 27 May 2021, 07:08 AM

Hello Cameron,

There is nothing wrong in the posted Scheduler configuration, so the problem most likely is data-related.

We would advise checking whether the  Basic_Usage_Read action is hit, and if it is, what data it returns back to the client. Check the response of the request the Scheduler sends to the action in the browser's devtools Network tab. You can compare it to the response in our demos, which looks like this:

{
   "Data":[
      {
         "TaskID":4,
         "Title":"Bowling tournament",
         "Description":"",
         "Start":"\/Date(1370811600000)\/",
         "StartTimezone":null,
         "End":"\/Date(1370822400000)\/",
         "EndTimezone":null,
         "RecurrenceRule":null,
         "RecurrenceID":null,
         "RecurrenceException":null,
         "IsAllDay":false,
         "OwnerID":2
      },
      {
         "TaskID":5,
         "Title":"Take the dog to the vet",
         "Description":"",
         "Start":"\/Date(1370847600000)\/",
         "StartTimezone":null,
         "End":"\/Date(1370851200000)\/",
         "EndTimezone":null,
         "RecurrenceRule":null,
         "RecurrenceID":null,
         "RecurrenceException":null,
         "IsAllDay":false,
         "OwnerID":2
      },
      {
         "TaskID":6,
         "Title":"Call Charlie about the project",
         "Description":"",
         "Start":"\/Date(1370950200000)\/",
         "StartTimezone":null,
         "End":"\/Date(1370955600000)\/",
         "EndTimezone":null,
         "RecurrenceRule":null,
         "RecurrenceID":null,
         "RecurrenceException":null,
         "IsAllDay":false,
         "OwnerID":2
      },
      {
         "TaskID":7,
         "Title":"Meeting with Alex",
         "Description":"",
         "Start":"\/Date(1371034800000)\/",
         "StartTimezone":null,
         "End":"\/Date(1371038400000)\/",
         "EndTimezone":null,
         "RecurrenceRule":null,
         "RecurrenceID":null,
         "RecurrenceException":null,
         "IsAllDay":false,
         "OwnerID":3
      }
   ],
   "Total":55,
   "AggregateResults":null,
   "Errors":null
}

For brevity I've posted part of the response (just 4 out of a total of 55 events returned).

Regards,
Ivan Danchev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Asked by
cameron
Top achievements
Rank 1
Iron
Answers by
cameron
Top achievements
Rank 1
Iron
Ivan Danchev
Telerik team
Share this question
or