Edit this page

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".

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);
  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();
  console.log(books[0].title); // displays "Secrets of the JavaScript Ninja"
});
</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