New to Kendo UI for jQueryStart a free 30-day trial

Schema

configuration

The schema configuration. See the DataSource.schema configuration for all available options.

schema

Object
<script>
var dataSource = new kendo.data.HierarchicalDataSource({
    data: [
        { name: "Documents", items: [
            { name: "Report.pdf", size: "1MB" },
            { name: "Presentation.pptx", size: "5MB" }
        ]},
        { name: "Images", items: [
            { name: "photo1.jpg", size: "2MB" },
            { name: "photo2.png", size: "3MB" }
        ]}
    ],
    schema: {
        model: {
            children: "items",
            fields: {
                name: { type: "string" },
                size: { type: "string" }
            }
        }
    }
});

dataSource.read();
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(dataSource.view().length); // displays 2
</script>
Object|kendo.data.Node

The data item (model) configuration. See the DataSource.schema.model configuration for all available options.

The model must inherit from kendo.data.Node.

<script>
var CustomNode = kendo.data.Node.define({
  averageRating: function() {
    var movies = this.children.data();
    var rating = 0;

    if (movies.length) {
      $.each(movies, function() { rating += this.rating; });
      rating /= movies.length;
    }

    return rating.toFixed(2);
  }
});

var datasource = new kendo.data.HierarchicalDataSource({
  data: [
    { categoryName: "SciFi", items: [
      { movieName: "Inception", rating: 8.8 },
      { movieName: "The Matrix", rating: 8.7 }
    ] },
    { categoryName: "Drama", hasAssignedMovies: true }
  ],
  schema: {
    model: CustomNode
  }
});

datasource.read();

var category = datasource.data()[0];
category.load();
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(category.averageRating()); // logs 8.75
</script>
In this article
schemaschema.model
Not finding the help you need?
Contact Support