Code Monkey home page Code Monkey logo

Comments (14)

yoavaa avatar yoavaa commented on July 23, 2024

just add it to the model, as in the docs
http://wix.github.io/angular-tree-control/#changing

from angular-tree-control.

abdualghsbsoft avatar abdualghsbsoft commented on July 23, 2024

How do i remove node?

from angular-tree-control.

yoavaa avatar yoavaa commented on July 23, 2024

exactly the same - update your model.

from angular-tree-control.

buob avatar buob commented on July 23, 2024

Is there an approach you had in mind for removing a node? The only way I can think of removing a node (from the actual node itself, i.e. a delete button on the node itself) out of the box is emit an event with the node to the containing controller and then walk the tree data and remove it from there. It seems less than ideal, is there another mechanism that would allow that kind of thing?

from angular-tree-control.

yoavaa avatar yoavaa commented on July 23, 2024

what would you imagine the tree doing?

On Wed, Jun 24, 2015 at 11:50 PM, Jake Buob [email protected]
wrote:

Is there an approach you had in mind for removing a node? The only way I
can think of removing a node (from the actual node itself, i.e. a delete
button on the node itself) out of the box is emit an event with the node to
the containing controller and then walk the tree data and remove it from
there. It seems less than ideal, is there another mechanism that would
allow that kind of thing?


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

from angular-tree-control.

buob avatar buob commented on July 23, 2024

I didn't know if there was something in place for a node to have knowledge of its parent so it could send the parent with the event and the directive could remove the node from the parent's children, or if there was an event already that a node could fire to its parent to remove itself. If either of those options sound interesting, I could investigate and submit a PR.

from angular-tree-control.

sethkrasnianski avatar sethkrasnianski commented on July 23, 2024

Any insight into this @yoavaa? I'm interested in doing the same thing that @buob is describing. I have a button next to each node which intends to remove said node from the tree, but to actually repaint the tree requires somehow walking the treeModel to find this node and removing it. Unless of course we're exposed the path to the current node somehow. It seems like there could / should be an easier way to do this.

from angular-tree-control.

yoavaa avatar yoavaa commented on July 23, 2024

in another issue we have a discussion on getting, for a node, the path of parents to the root (or rather, the path to a node). While this is possible, it is not trivial and I am not sure about the API. It has to be a function that we can expose similar to the other tree label template variables (e.g. http://wix.github.io/angular-tree-control/#labels-template and http://wix.github.io/angular-tree-control/#events).

Do you think adding a $parents which is a function returning an array of nodes will help?

from angular-tree-control.

paambaati avatar paambaati commented on July 23, 2024

@yoavaa That should definitely help. I too have a usecase that requires deleting nodes!

from angular-tree-control.

paambaati avatar paambaati commented on July 23, 2024

@buob @sethkrasnianski Did you guys manage to find a workaround for this?

from angular-tree-control.

yoavaa avatar yoavaa commented on July 23, 2024

@paambaati what is the usecase?

If it is that when a node is clicked you want to remove it, you can use the $parentNode parameter you get in events. With it you can get the parent node of the clicked node and remove it from the parent.

from angular-tree-control.

buob avatar buob commented on July 23, 2024

I think we were using a version before $parentNode was available, so we ended up just storing parentNode on each node ourselves before sending it to tree control and removing it that way.

from angular-tree-control.

developingdenny avatar developingdenny commented on July 23, 2024

I am updating my treeModel by splicing children OUT of the structure. Although the tree model updates as expected, the tree's transcludeScope goes out of synch with the new data structure.

The result is that the tree's label continues to display the removed node's data even while the scope's node property is properly updated.

Am I missing something necessary in order to successfully remove nodes?

from angular-tree-control.

developingdenny avatar developingdenny commented on July 23, 2024

Just an update to my prior question:

I discovered transcludeScopes for removed nodes remain synchronized with treeModel updates whenever NOT using the custom template option.

from angular-tree-control.

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.