parentId(default: "{ type: 'number', nullable: true }")
The name of the Model's parentId field. The Kendo UI TreeList distinguishes the root items based on the parentId field. If the schema.model.fields.[parentIdField] is nullable, root items with be items whose parentId field values are null. If the schema.model.fields.[parentIdField] is not nullable, root items will be items which have a default value for their data type.
Example
<div id="treeList"></div>
<script>
var dataSource = new kendo.data.TreeListDataSource({
data: [
{ id: 1, name: "John Doe", parentId: null },
{ id: 2, name: "Jane Smith", parentId: 1 },
{ id: 3, name: "Bob Johnson", parentId: 1 },
{ id: 4, name: "Alice Brown", parentId: 2 }
],
schema: {
model: {
id: "id",
parentId: "parentId",
fields: {
parentId: { type: "number", nullable: true }
}
}
}
});
$("#treeList").kendoTreeList({
dataSource: dataSource,
columns: ["name"]
});
// Access the parentId configuration
var model = dataSource.options.schema.model;
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log("ParentId field configuration:", model.parentId);
</script>
In this article