data Array|String

The array of data items which the data source contains. The data source will wrap those items as kendo.data.ObservableObject or kendo.data.Model (if schema.model is set).

Can be set to a string value if the schema.type option is set to "xml".

A field in the DataSource cannot be named "data". The latter should be considered a limitation.

Example - set the data items of a data source

<script>
var dataSource = new kendo.data.DataSource({
  data: [
    { name: "Jane Doe", age: 30 },
    { name: "John Doe", age: 33 }
  ]
});
dataSource.fetch(function(){
  var janeDoe = dataSource.at(0);
/* The result can be observed in the DevTools(F12) console of the browser. */
  console.log(janeDoe.name); // displays "Jane Doe"
});
</script>

Example - set the data items as an XML string

<script>
var dataSource = new kendo.data.DataSource({
  data: '<books><book id="1"><title>Secrets of the JavaScript Ninja</title></book></books>',
  schema: {
    // specify the the schema is XML
    type: "xml",
    // the XML element which represents a single data record
    data: "/books/book",
    // define the model - the object which will represent a single data record
    model: {
      // configure the fields of the object
      fields: {
        // the "title" field is mapped to the text of the "title" XML element
        title: "title/text()",
        // the "id" field is mapped to the "id" attribute of the "book" XML element
        id: "@id"
      }
    }
  }
});
dataSource.fetch(function() {
  var books = dataSource.data();
/* The result can be observed in the DevTools(F12) console of the browser. */
  console.log(books[0].title); // displays "Secrets of the JavaScript Ninja"
});
</script>
In this article