data Array|String

The array of data items which the data source contains. The data source will wrap those items as or (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

var dataSource = new{
  data: [
    { name: "Jane Doe", age: 30 },
    { name: "John Doe", age: 33 }
  var janeDoe =;
  console.log(; // displays "Jane Doe"

Example - set the data items as an XML string

var dataSource = new{
  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 =;
  console.log(books[0].title); // displays "Secrets of the JavaScript Ninja"
In this article
Not finding the help you need? Improve this article