-
Notifications
You must be signed in to change notification settings - Fork 301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Angular Tree with lazy loading #90
Comments
I was struggling with this too but I have found a solution: // NavTree object
$scope.files = [];
var tree;
$scope.my_tree = tree = {};
// Load root folder
Factory.method().then(function (response) {
$scope.files = response.data;
});
/**
* Load branch
* @param {string} branch
*/
$scope.loadBranch = function (branch) {
Factory.method().then(function (response) {
// Add branches
response.forEach(function (value, key) {
tree.add_branch(branch, value);
});
});
} And your HTML: <abn-tree tree-data="files"
icon-leaf="fa fa-file"
icon-expand="fa fa-folder"
icon-collapse="fa fa-folder-open"
on-select="loadBranch(branch)"
tree-control="my_tree"
></abn-tree> The implementation of the If you find a solution for this please contact me. Edit: You can use the |
I figure out this problem by adding children to the branch when it is clicked.the solution could click this page. http://blog.csdn.net/baidu_35407267/article/details/52457779 |
thank you @guguji5. I have taken your solution and translated to english and adapted to the sample test tree. In this case, I have added the i_click function to the Venezuela branch under South America
Within the abn_tree_directive.js, this is the change to add i_click(row) to the ng-click event replacing the original a.branch.expanded = !a.branch.expanded on line 11 next to the image
Then add the i_click function to abn_tree_derective.js links (I put this right after scope.user_clicks_branch function definition after lines 105-109)
In the controller code for the tree control add the function pull_data which the Venezuela i_click value was assigned. This is the code that will execute when the Venezuela branch is expanded. Note: you will need to have this function defined before assigning it to the Venezuela branch to avoid the error of pull_data function is not defined.
|
For anyone interested here is the same pull_data function using an $http post promise to retrieve data asynchronously
Controller action to retrieve data is
|
@pneborg I am so sorry to see your message just now,my project is to heavy to have little time this week.is that you have figured it out? |
Hi @guguji5 Thank you for providing your initial answer. It was great to have this question resolved. All I did was translate it and set up an example. 👍 |
I am looking for a treeview where child nodes are retrieved from the API call and appended to the parent, for this first time all parent nodes should be populated and when u click on parent node it should make a API call to get all the child nodes for that parent node and populate it like lazy loading.
Do we have any implementation demo anywhere, all the examples I am seeing are just retrieving data in one shot with parent child relationship and loading them at once. I wish to make an API call to get child elements, any help is appreciated thank you :)
The text was updated successfully, but these errors were encountered: