Edit this page

transport.push Function

The function invoked during transport initialization which sets up push notifications. The data source will call this function only once and provide callbacks which will handle push notifications (data pushed from the server).

Parameters

callbacks Object

An object containing callbacks for notifying the data source of push notifications.

callbacks.pushCreate Function

Function that should be invoked to notify the data source about newly created data items that are pushed from the server. Accepts a single argument - the object pushed from the server which should follow the schema.data configuration.

callbacks.pushDestroy Function

Function that should be invoked to notify the data source about destroyed data items that are pushed from the server. Accepts a single argument - the object pushed from the server which should follow the schema.data configuration.

callbacks.pushUpdate Function

Function that should be invoked to notify the data source about updated data items that are pushed from the server. Accepts a single argument - the object pushed from the server which should follow the schema.data configuration.

Example

<script src="http://ajax.aspnetcdn.com/ajax/signalr/jquery.signalr-1.1.3.min.js"></script>
<script>
var hubUrl = "https://demos.telerik.com/kendo-ui/service/signalr/hubs";
var connection = $.hubConnection(hubUrl, { useDefaultPath: false});
var hub = connection.createHubProxy("productHub");
var hubStart = connection.start({ jsonp: true });
var dataSource = new kendo.data.DataSource({
transport: {
  push: function(callbacks) {
    hub.on("create", function(result) {
      console.log("push create");
      callbacks.pushCreate(result);
    });
    hub.on("update", function(result) {
      console.log("push update");
      callbacks.pushUpdate(result);
    });
    hub.on("destroy", function(result) {
      console.log("push destroy");
      callbacks.pushDestroy(result);
    });
  }
},
schema: {
  model: {
    id: "ID",
    fields: {
      "ID": { editable: false },
      "CreatedAt": { type: "date" },
      "UnitPrice": { type: "number" }
    }
  }
}
});
</script>
Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article

close
Dummy