read

Reads data items from a remote/custom transport (if the transport option is set) or from a JavaScript array (if the data option is set).

The read method always makes a request to the remote service unless the Data Source is offline.

Parameters

data Object (optional)

Optional data to pass to the remote service. If you need to filter, it is better to use the filter() method or the query() method with a filter parameter.

Returns

Promise—A promise that will be resolved when the data has been loaded or rejected if an HTTP error occurs.

Example - read data from a remote service

<script>
var dataSource = new kendo.data.DataSource({
  transport: {
    read: {
      url: "https://demos.telerik.com/kendo-ui/service/products",
      dataType: "jsonp"
    }
  },
  change: function(e) {
    var view = this.view();
/* The result can be observed in the DevTools(F12) console of the browser. */
    console.log(view[0].ProductName); // displays "Chai"
  }
});

var optionalData = { foo: 42, bar: "baz" };

dataSource.read(optionalData);
</script>

Example - use the Promise API to track when a request finishes

<script>
var dataSource = new kendo.data.DataSource({
  transport: {
    read: {
      url: "https://demos.telerik.com/kendo-ui/service/products",
      dataType: "jsonp"
    }
  }
});

dataSource.read().then(function() {
  var view = dataSource.view();
/* The result can be observed in the DevTools(F12) console of the browser. */
  console.log(view[0].ProductName); // displays "Chai"
});
</script>
In this article