Skip to content
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

Lazy loading on parent node #27

Open
Saideprinz opened this issue Apr 10, 2015 · 25 comments
Open

Lazy loading on parent node #27

Saideprinz opened this issue Apr 10, 2015 · 25 comments

Comments

@Saideprinz
Copy link

Can i do lazy loading in Expand button. Is there any event binding available for it. I need to do lazy loading and add data on the fly during expansion of parent node. Is it viable in this ngJSTree.

Once selections are made i need to send back Checked values alone. Can we do it in this component. Thanks for your help.

@ezraroi
Copy link
Owner

ezraroi commented Apr 10, 2015

Hi, you should bind for the select or expend events. In the jstree documentation you can find some examples

@ezraroi ezraroi closed this as completed Apr 10, 2015
@Saideprinz
Copy link
Author

I saw the JStree documentation but i couldnt get the basic ajax demo code. And also its not in angular js. Could you please help me with an angular example using ngJStree for binding event to do lazy load on parent node click. I am very new to angularjs and this plugin. Thanks for your help in advance.

@hiteshgaur
Copy link

I would also like to have a sample code for ngJsTree with lazy loading. I am able to bind it correctly for the first time by making a separate $http call and recreating the tree instance, but when expanding a node which will need to load children asynchronously it produces following error.

error from js tree - {"error":"nodata","plugin":"core","id":"core_05","reason":"Could not load node","data":"{"id":"4"}"}

if thread has been closed with any solution, it would have been better.

Thanks in advance.

@ezraroi ezraroi reopened this May 13, 2015
@Mateo-Luzi
Copy link

Yea I also have this problem. The only way that ngJsTree will detect any model changes is when I re-create the tree with version++. If I push anything to the treeData array, nothing happens (if I don't re-create). This problem has been plaguing me for a week now and I have no idea what I can still try to solve this...

@ezraroi
Copy link
Owner

ezraroi commented May 13, 2015

You can see in the demo page that changes are detected automatically without tree recreation

@Mateo-Luzi
Copy link

Liujoey's fix from issue #14 worked for me for whatever reason.

@AlenkaM
Copy link

AlenkaM commented May 27, 2015

Hello! Did you make any progress with issue #27?

I am receiving the same error, when trying to call a function on 'before_open' event, having children: true property in my object.

error from js tree - {"error":"nodata","plugin":"core","id":"core_05","reason":"Could not load node","data":"..

I set this property to true in order to get expand icon shown, when node does not have children.

I did not find any other way to show expand icon without assigning a child object, which I am trying to avoid, because it will slow down my application considerably.

@ezraroi
Copy link
Owner

ezraroi commented May 29, 2015

Will try to implement this, but i am not sure i will have time in near future.

@AlenkaM
Copy link

AlenkaM commented May 29, 2015

Ok, it can be really great if you solve it.

As a workaround, I am applying an empty child object now. Then set propery li_attr ={class: "hidden"} to this child. So after the list is expanded the empty child is not shown. Maybe this can help somebody.

@jainsaurabh83
Copy link

As workaround I tried to add dummy node and on expand (before_open) i deleted that dummy node.
But when i delete dummy node it selects the parent. please look into checkbox plugin as well

@icruces
Copy link

icruces commented Aug 4, 2015

+1 "children: true" issue

@vsonone
Copy link

vsonone commented Sep 22, 2015

Looks like the data option for ngjstree is overridden by the following block in getOptions() method. If I comment the line config.core.data = scope.treeData, then the ngjstree starts working with ajax mode. But I have not tested other behavior of the tree. Thoughts ?
if (config.core) {
// config.core.data = scope.treeData;
}
else {
config.core = { data: scope.treeData };
}

@ezraroi
Copy link
Owner

ezraroi commented Sep 22, 2015

The angular tree should not work with Ajax. When you comment this line you break the 2 way binding. You can load in Ajax data but you should add it to the array of the nodes inside apply cycle

@vsonone
Copy link

vsonone commented Sep 22, 2015

Yeah, after further testing, I found that.

I have a tree which can have potential 60K nodes, what are my alternatives ? If I load everything at once, then tree becomes unresponsive and often leads to a browser crash, not a good user experience.

Any suggestions ?

@ezraroi
Copy link
Owner

ezraroi commented Sep 23, 2015

Catch the right event if the tree and load your data async with $http or Ajax. After it create nodes objects and push them to the 2 way binding array.... this should work. Check the demo page

@gaving
Copy link

gaving commented Oct 27, 2015

@AlenkaM 👍 for the suggested workaround, hours trying to debug the non firing of before_open!

@gauravbhavsar
Copy link

Any update on children: true issue ?
Having same problem.

@ezraroi
Copy link
Owner

ezraroi commented Dec 6, 2015

did you try the workaround of @AlenkaM ?

@gauravbhavsar
Copy link

Yes, for now I am using befor_open to load grandChild.

@renandegrandi
Copy link

+1 Child true, and not be necessary to rebuild the entire tree

@tolya199178
Copy link

How can I setting loading icon while loading data?

@vrohini
Copy link

vrohini commented Nov 7, 2016

HI All,

I am using
function beforeOpen(e, item) {

//and trying to assign children to parent node
}

I can see the $scope.treeData is update but my tree is not refreshed with new data and clue?

@7899
Copy link

7899 commented Nov 9, 2016

Is there a way to set Children to True yet? If not then can someone please give an example of @AlenkaM workaround? I don't fully understand how to implement the part in bold:

As a workaround, I am applying an empty child object now. Then set propery li_attr ={class: "hidden"} to this child. So after the list is expanded the empty child is not shown. Maybe this can help somebody.

Thanks.

@sauliuni
Copy link

@7899 just set to your item following property:
item.li_attr = {class:'hidden'};

@dmitryt
Copy link

dmitryt commented Dec 8, 2016

Hello. I was faced with the same problem. As a workaround I used function for ng-model:

vm.treeData = function(node, cb) {
    loadChildren(node.id).then(function(res) {
        cb(prepareData(res));
    })
}

AFAIU, it's handled here.
I'm not sure that it's the best solution, but it works for me =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests