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

Am I missing something here?

1 Answer 80 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 07 Jul 2014, 10:28 AM
I figured the demos are pretty straight forward but i get the impression I need to specify something that is currently missing.

Can anyone see what I missed?

I had to change the line "var hubStart = connection.start({ jsonp: true });" to "var hubStart = connection.start();" because i got a "jsonp is disabled" error, I read up on it and my understanding was that this was a cross domain feature which I don't need since im only pulling data from a hub on the current app / domain so i took it out.
I also got the impression that this was regression from the COR stuff which is event driven rather than polling (so less advanced forcing a regression).

So here's my MVC view code ...

01.@section scripts
02.{
03.<script>
04.    $(function () {
05.        var hubUrl = "/signalr/hubs";
06.        var connection = $.hubConnection(hubUrl, { useDefaultPath: false });
07.        var hub = connection.createHubProxy("submissionHub");
08.        var hubStart = connection.start();
09. 
10.        $("#notification").kendoNotification({
11.            width: "100%",
12.            position: {
13.                top: 0,
14.                left: 0
15.            }
16.        });
17.        $("#grid").kendoGrid({
18.            editable: true,
19.            sortable: true,
20.            dataSource: {
21.                type: "signalr",
22.                autoSync: true,
23.                // Handle the push event to display notifications when push updates arrive
24.                push: function (e) {
25.                    var popupNotification = $("#popupNotification").data("kendoNotification");
26.                    popupNotification.show(e.type, "success");
27.                },
28.                schema: {
29.                    model: {
30.                        id: "SubmissionId",
31.                        fields: {
32.                            "SubmissionId": { editable: false },
33.                            "FirstName": { type: "text" }
34.                        }
35.                    }
36.                },
37.                sort: [{ field: "SubmissionId", dir: "desc" }],
38.                transport: {
39.                    signalr: {
40.                        promise: hubStart,
41.                        hub: hub,
42.                        server: {
43.                            read: "read",
44.                            update: "update",
45.                            destroy: "destroy",
46.                            create: "create"
47.                        },
48.                        client: {
49.                            read: "read",
50.                            update: "update",
51.                            destroy: "destroy",
52.                            create: "create"
53.                        }
54.                    }
55.                }
56.            }
57.        });
58.    });
59. 
60. 
61.</script>   
62.}
63. 
64.<div id="grid" data-role="grid" style="height: 200px">
65.</div>


And here's my hub code ...
For now it's a just simple "respond with what you get", notice that I have a hard coded static type called "Database", and Database.Submissions just returns a list of submission objects (as if to simulate a database call but from ram)

01.using Microsoft.AspNet.SignalR;
02.using Test_Project.Models;
03. 
04.namespace Test_Project.Hubs
05.{
06.    public class SubmissionHub : Hub
07.    {
08.        public void Read()
09.        {
10.            Clients.All.Read(Database.Submissions.ToArray());
11.        }
12. 
13.        public void Update(Submission submission)
14.        {
15.            Clients.All.Update(submission);
16.        }
17. 
18.        public void Destroy(Submission submission)
19.        {
20.            Clients.All.Destroy(submission);
21.        }
22. 
23.        public void Create()
24.        {
25.            Clients.All.Create(new Submission());
26.        }
27.    }
28.}

1 Answer, 1 is accepted

Sort by
0
Paul
Top achievements
Rank 1
answered on 07 Jul 2014, 10:47 AM
Ok i did the usual, wrote too much code then found an example on this forum showing that my hub code wasn't quite right ...

essentially i just needed to have my hub do this ...

1.public List<Submission> Read()
2.{
3.    return Database.Submissions;
4.}

Love the simplicity of kendo sometimes lol :)
Tags
Grid
Asked by
Paul
Top achievements
Rank 1
Answers by
Paul
Top achievements
Rank 1
Share this question
or