This is a migrated thread and some comments may be shown as answers.

Scheduler w/ SignalR

3 Answers 125 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 22 May 2014, 04:59 AM
Hello

I'm having an issue trying to bind my SignalR DataSource to the CRUD methods in my SignalR hub. Can you tell me where I am going wrong? When debugging the ScdLoad method isn't hit. However when this does work when it is a KendoGrid

My hub:

01.public IEnumerable<LogSchedulerModel> ScdLoad() {
02.            var logs = _entityProvider.QueryLogs(x => x.Where(l => l.CheckInExpected > DateTime.Now));
03.            var scdLogs = logs.Select(log => new LogSchedulerModel
04.            {
05.                ID = log.ID,
06.                CheckInExpected = log.CheckInExpected,
07.                StartDate = log.StartDate,
08.                CheckInActual = log.CheckInActual,
09.                ContactNumber = log.ContactNumber,
10.                UserName = log.UserName,
11.                Location = log.UserName,
12.                Start = log.StartDate,
13.                End = log.CheckInExpected,
14.                EmergencyContactName = log.EmergencyContactName,
15.                EmergencyContactNo = log.EmergencyContactNo
16.            });
17. 
18.            return scdLogs;
19.        }

My View:
@(Html.Kendo().Scheduler<LogSchedulerModel>()
        .Name("scheduler")
        .Date(DateTime.Now)
        .StartTime(DateTime.Now)
        .Height(600)
        .Views(views =>
        {
            views.DayView();
            views.WorkWeekView(workWeekView => workWeekView.Selected(true));
            views.WeekView();
            views.MonthView();
            views.AgendaView();
        })
        .DataSource(source => source
        .SignalR()
        .Events(events => events.Push(@<text>
            function(e) {
                var notification = $("#notification").data("kendoNotification");
                notification.success(e.type);
            }
        </text>))
        .Transport(tr => tr
            .Promise("hubStart")
            .Hub("hub")
            .Client(c => c
                .Create("scdcreate")
                .Read("scdload")
                .Update("scdupdate")
                .Destroy("scddestroy")
            )
            .Server(s => s
                .Create("scdcreate")
                .Read("scdload")
                .Update("scdupdate")
                .Destroy("scddestroy")
            ))
            .Schema(schema => schema
                .Model(model =>
                {
                    model.Id(m => m.ID);
                    model.Field(m => m.ID).Editable(true);
                })
            )
        )
)

3 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 26 May 2014, 07:08 AM
Hi David,

From the provided information it's not clear for us what is the exact reason for current behavior - could you please provide small isolated example where the issue is reproduced? This would help us pinpoint the exact reason for this behavior.

Regards,
Vladimir Iliev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
David
Top achievements
Rank 1
answered on 27 May 2014, 01:41 AM
01.@(Html.Kendo().Scheduler<LogSchedulerModel>()
02.            .Name("scheduler")
03.            .Date(DateTime.UtcNow)
04.            .StartTime(DateTime.UtcNow)
05.            .Height(600)
06.            .Timezone("Pacific/Auckland")
07.            .Views(views =>
08.            {
09.                views.DayView();
10.                views.WorkWeekView(workWeekView => workWeekView.Selected(true));
11.                views.WeekView();
12.                views.MonthView();
13.                views.AgendaView();
14.            })
15.            .DataSource(source => source
16.                .SignalR()
17.                .Transport(tr => tr
18.                    .Promise("hubStart")
19.                    .Hub("hub")
20.                        .Client(c => c
21.                            .Create("ScdCreate")
22.                            .Read("ScdRead")
23.                            .Update("ScdUpdate")
24.                            .Destroy("ScdDestroy")
25.                        )
26.                        .Server(s => s
27.                            .Create("ScdCreate")
28.                            .Read("ScdRead")
29.                            .Update("ScdUpdate")
30.                            .Destroy("ScdDestroy")
31.                        ))
32.                        .Schema(schema => schema
33.                        .Model(model =>
34.                        {
35.                            model.Id(p => p.ID);
36.                            model.Field(p => p.Start);
37.                            model.Field(p => p.End);
38.                            model.Field(p => p.IsAllDay);
39.                        })
40.                        )
41.                          
42.            )
43.    )

Ok, hope this helps define the scope a bit better. It's hitting my NotificationsHub now with the given changes above .. However when I create a new Scheduler Task, on Post Back, the values are not binding correctly. All the values are Empty Strings and the Dates for start and end are set to the current time. Also my Read method also does not display values in the Scheduler.

How am I meant to correctly receive the data on PostBack in my "ScdCreate" method, and send data to the scheduler in the SignalR hub?

01.public class NotificationHub : Hub
02.{
03.        public IEnumerable<LogSchedulerModel> ScdRead()
04.        {
05.            var logs = _entityProvider.QueryLogs(x => x.Where(l => l.CheckInExpected > DateTime.Now));
06.            var scdLogs = logs.Select(log => new LogSchedulerModel
07.            {
08.                Title = log.ID.ToString(),
09.                Start = DateTime.Now,
10.                End = log.CheckInExpected,
11.            }).ToList();
12. 
13.            return scdLogs;
14.        }
15. 
16.        public LogSchedulerModel ScdCreate( LogSchedulerModel log)
17.        {
18.            //_entityProvider.AddLog(log);
19.            //Clients.Others.create(log);
20.            return log;
21.        }
22.}
0
Vladimir Iliev
Telerik team
answered on 28 May 2014, 12:55 PM
Hi David,

Apologise for misleading you - the reason for the events not being loaded is that the DataSource Model configuration is invalid. I would suggest to use the initial version of the "ScdLoad" Action (where all fields are send to the client side) and the following settings of the DataSource Model (all fields from the ISchedulerEvent should be translated to lowercase on the client side):

.Schema(schema => schema
    .Model(model =>
    {
        model.Id(p => p.ID);
        model.Field("title", typeof(string)).DefaultValue("No title").From("Title");
        model.Field("start", typeof(DateTime)).From("Start");
        model.Field("end", typeof(DateTime)).From("End");
        model.Field("description", typeof(string)).From("Description");
        model.Field("recurrenceRule", typeof(string)).From("RecurrenceRule");
        model.Field("recurrenceException", typeof(string)).From("RecurrenceException");
        model.Field("isAllDay", typeof(bool)).From("IsAllDay");
        model.Field("startTimezone", typeof(string)).From("StartTimezone");
        model.Field("endTimezone", typeof(string)).From("EndTimezone");
    })
)

Regards,
Vladimir Iliev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Scheduler
Asked by
David
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
David
Top achievements
Rank 1
Share this question
or