Kendo Ui Grid Signalr
HTML
<link rel="stylesheet" href="//kendo.cdn.telerik.com/2015.3.930/styles/kendo.common.min.css">
<link rel="stylesheet" href="//kendo.cdn.telerik.com/2015.3.930/styles/kendo.flat.min.css">
<script src="//kendo.cdn.telerik.com/2015.3.930/js/jquery.min.js"></script>
<script src="//kendo.cdn.telerik.com/2015.3.930/js/kendo.all.min.js"></script>
<script src="http://testkzndot.smartcitizen.co.za/Scripts/jquery.signalR-2.2.0.js?b=1.1.0.0"></script>
<div id="example">
<div id="grid" style="margin-bottom:20px"></div>
<span id="notification"></span>
<div class="box wide">
<h4>Information</h4>
<p>This example demonstrates real-time push-notifications from <a href="http://signalr.net/">SignalR</a>. To see the real-time updates:</p>
<ol>
<li>Open this page in another browser window by clicking <a href="./signalr" target="_new">here</a></li>
<li>Create, update or destroy grid items.</li>
</ol>
<p><strong>Note:</strong> To further enhance real-time experience, the Grid will also display changes from other users,
which currently happen to perform CRUD operations on the same demo.
If you refresh the page, all changes will be lost, because the remote service only broadcasts changes, it does not actually save them.</p>
</div>
</div>
JavaScript
$(function(){
var hubUrl = "http://testkzndot.smartcitizen.co.za/signalr/hubs";
var connection = $.hubConnection(hubUrl, { useDefaultPath: false});
var echo = connection.createHubProxy("monitorhub");
echo.on("onConsoleMessage", function (val) {
// alert(va);
console.log(val);
});
connection.start({jsonp:true});
/* $("#notification").kendoNotification({
width: "100%",
position: {
top: 0,
left: 0
}
});
$("#grid").kendoGrid({
height: 550,
editable: true,
sortable: true,
columns: [
{ field: "UnitPrice" },
{ field: "ProductName" },
{ command: "destroy", width: 150}
],
toolbar: ["create"],
dataSource: {
type: "signalr",
autoSync: true,
// Handle the push event to display notifications when push updates arrive
push: function(e) {
var notification = $("#notification").data("kendoNotification");
notification.success(e.type);
},
schema: {
model: {
id: "ID",
fields: {
"ID": { editable: false, nullable: true },
"CreatedAt": { type: "date" },
"UnitPrice": { type: "number" }
}
}
},
sort: [ { field: "CreatedAt", dir: "desc" }],
transport: {
signalr: {
promise: hubStart,
hub: hub,
...