Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions DOCUMENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ $scope.$callbacks = {
beforeDrop: function (event) {
return true;
},
loadChildren: function (node) {
// return array or promise resolved with children
},
calsIndent: function (level) {
if (level - 1 < 1) {
return $scope.indent_plus + ($scope.indent_unit ? $scope.indent_unit : 'px');
Expand All @@ -294,6 +297,30 @@ $scope.$callbacks = {
}
};
```

* Lazy load children on expand:
* Mark nodes that have unloaded children with `node.__has_children__ = true` or `node.__lazy__ = true` so the expand icon is shown.
* Provide `callbacks.loadChildren` to return an array (sync) or a promise that resolves to an array (async).
* When `loadChildren` resolves, children are inserted into `node.__children__`, the node expands, and the tree is reloaded.
* Example:
```js
$scope.tree_data = [{
title: 'Root',
__lazy__: true,
__children__: []
}];

$scope.callbacks = {
loadChildren: function (node) {
return $http.get('/api/tree/' + node.id + '/children').then(function (res) {
return res.data;
});
}
};
```
```html
<tree-dnd tree-data="tree_data" callbacks="callbacks"></tree-dnd>
```
* Functions extended in control (attribute 'tree-control'):

```html
Expand Down
Loading