Last active
June 20, 2017 08:30
-
-
Save deniskyashif/bbf9be4d4c6e2bec7f3302ad9651d3d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// hard-code that the item will always have children | |
hasChildren: true | |
// map the hasChildren property to the hasSubordinates field, serialized from the server | |
hasChildren: "hasSubordinates" | |
// compute whether the given item will have children | |
hasChildren: function(item) { | |
return item.hasEmployees && item.relatedDepartment; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var dataSource = new kendo.data.TreeListDataSource({ | |
data: [ | |
{ employeeId: 1, name: 'Montgomery Burns', reportsTo: null, hasSubordinates: true }, | |
{ employeeId: 2, name: "Homer Simpson", reportsTo: 1, hasSubordinates: false }, | |
{ employeeId: 3, name: "Lenford Leonard", reportsTo: 1, hasSubordinates: false } | |
] | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var treeListDataSource = new kendo.data.TreeListDataSource({ | |
transport: { | |
read: { | |
url: 'api/employees', | |
type: 'GET', | |
dataType: 'json' | |
} | |
}, | |
schema: { /* ... */ } | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var treeListDataSource = new kendo.data.TreeListDataSource({ | |
transport: { /* ... */ }, | |
schema: { | |
// property mapping | |
model: { | |
id: 'employeeId', // unique id field name | |
parentId: 'reportsTo', // relation with another record's id | |
hasChildren: 'hasSubordinates', // indicates that there're records that haven't been loaded | |
fields: { | |
employeeId: { type: 'number', nullable: false }, | |
name: { type: 'string', nullable: false }, | |
reportsTo: { type: 'number', nullable: true } | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment