Git Product home page Git Product logo

Comments (19)

ezraroi avatar ezraroi commented on July 30, 2024

Hi,
can you write a plunker with the code? basically you don't have to force, the update should happen automatically. You can look on the demo code for example. Are you using $http to load the data async?

from ngjstree.

christophla avatar christophla commented on July 30, 2024

I’m using typescript and rectangular (repository). The data.industryHierarchy contains the array of valid nodes. I’m also using the child array approach (versus the parent id).

repositories.industryHierarchy.search($scope.query, IndustryClassification.Any).then(function (data) {
$scope.loading = false
$scope.treeData = data.industryHierarchy
}, function (response) {
$scope.loading = false
$scope.errormessage = response.data.message
services.logger.error('An error occurred searching', response.data)
})

On Oct 30, 2014, at 4:40 PM, Roi Ezra [email protected] wrote:

Hi,
can you write a plunker with the code? basically you don't have to force, the update should happen automatically. You can look on the demo code for example. Are you using $http to load the data async?


Reply to this email directly or view it on GitHub #7 (comment).

from ngjstree.

christophla avatar christophla commented on July 30, 2024

If I manually drop in the array, I can see that it supports the parent / child array format.

from ngjstree.

ezraroi avatar ezraroi commented on July 30, 2024

my guess is that there is not dirty checking of angular after the promise is resolved, try to update the tree data inside a $timeout or inside $apply, i think that it will solve your problem

from ngjstree.

christophla avatar christophla commented on July 30, 2024

That’s likely. I’ve run into this before… but at the same time, I use the exact same approach to update grids and repeaters and it works just fine.

On Oct 30, 2014, at 4:46 PM, Roi Ezra [email protected] wrote:

my guess is that there is not dirty checking of angular after the promise is resolved, try to update the tree data inside a $timeout or inside $apply, i think that it will solve your problem


Reply to this email directly or view it on GitHub #7 (comment).

from ngjstree.

ezraroi avatar ezraroi commented on July 30, 2024

I would also suggest that you initialize the treeData with empty array and just push all the nodes to that array once the promise is resolved, because otherwise you are changing the array reference after the tree was created.

from ngjstree.

christophla avatar christophla commented on July 30, 2024

My same implementation works fine with https://github.com/arvindr21/jsTree-directive https://github.com/arvindr21/jsTree-directive

I ported to yours because I need the ability to set the tree instance to a scope variable….

On Oct 30, 2014, at 4:40 PM, Roi Ezra [email protected] wrote:

Hi,
can you write a plunker with the code? basically you don't have to force, the update should happen automatically. You can look on the demo code for example. Are you using $http to load the data async?


Reply to this email directly or view it on GitHub #7 (comment).

from ngjstree.

ezraroi avatar ezraroi commented on July 30, 2024

Did you try to initialize the array like i suggested? If you still have the problem i would need a way to reproduce it as loading async data works fine for me on my projects.

from ngjstree.

christophla avatar christophla commented on July 30, 2024

If you were to change the scope watcher in you code to look at the array instance versus the array contents, how would you go about it?

On Oct 30, 2014, at 4:51 PM, Roi Ezra [email protected] wrote:

I would also suggest that you initialize the treeData with empty array and just push all the nodes to that array once the promise is resolved, because otherwise you are changing the array reference after the tree was created.


Reply to this email directly or view it on GitHub #7 (comment).

from ngjstree.

ezraroi avatar ezraroi commented on July 30, 2024

I think that it will miss the whole point of the binding. You don't want to change the array instance on every new item or updated item in the tree. If you want to replace the whole array content you ca do this with the should-apply method. Set the method to return false before you clear the array, make all the changes in the array, update a version property in the jsTree config object, this will cause the tree to destroyed and created again with the new data

from ngjstree.

christophla avatar christophla commented on July 30, 2024

I have a deliverable and will figure it out tomorrow. Until then, it's angular scope madness.

from ngjstree.

ezraroi avatar ezraroi commented on July 30, 2024

Hi,
i added a section in the ReadMe that explains about how to recreate the tree.

from ngjstree.

ezraroi avatar ezraroi commented on July 30, 2024

I also added async load and tree recreate examples in the demo page of the directive (http://ezraroi.github.io/ngJsTree/). I hope this can help you

from ngjstree.

christophla avatar christophla commented on July 30, 2024

I applied the timeout to the callback and the tree loaded. Thanks!

P.S. Do you have any examples for asynchronously loading child nodes on expand? Should I catch the expand event and add them then?

from ngjstree.

ezraroi avatar ezraroi commented on July 30, 2024

Hi, yes. This is right way to do this as i see it. Subscribe for the event, and load the data async and add it to the nodes array.

from ngjstree.

christophla avatar christophla commented on July 30, 2024

Thanks again!

from ngjstree.

ezraroi avatar ezraroi commented on July 30, 2024

np

from ngjstree.

brunolellis avatar brunolellis commented on July 30, 2024

Hello @ezraroi,
It looks like the 'parent' attribute is required for this async operation.

Do you know if there is a way to configure parent as default to '#'?

Thanks!

from ngjstree.

elahekaramzade avatar elahekaramzade commented on July 30, 2024

hi . im using angularjs and $http service , and have this issue too . any help ?

from ngjstree.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.